/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 1ms 532.0 KiB
#3 Accepted 1ms 532.0 KiB
#4 Accepted 1ms 532.0 KiB
#5 Accepted 14ms 532.0 KiB
#6 Accepted 10ms 532.0 KiB
#7 Accepted 22ms 2.02 MiB
#8 Accepted 38ms 2.07 MiB
#9 Accepted 36ms 2.066 MiB
#10 Accepted 34ms 2.066 MiB
#11 Wrong Answer 11ms 532.0 KiB
#12 Wrong Answer 11ms 544.0 KiB

Code

#include <bits/stdc++.h>
using namespace std;
#define SC               scanf
#define PF               printf
#define ull              unsigned long long
#define ld               long double
#define F                first
#define S                second
#define pb               push_back
#define sort_a(a)        sort(a.begin(),a.end());
#define sort_d(a)        sort(a.rbegin(),a.rend());
#define READ(f)          freopen(f, "r", stdin)
#define WRITE(f)         freopen(f, "w", stdout)
#define rev(s)           reverse(s.begin(),s.end())
#define P(ok)            cout << (ok ? "YES\n": "NO\n")
#define __Heart__              ios_base :: sync_with_stdio(false); cin.tie(NULL);
#define ll long long
typedef pair< ll , ll>                   PII;
void solve()
{
   ll n , Roy = 0 , Hridoy = 0; cin >> n ; ll a[n] ;
   for(auto &x : a) cin >> x ;
   sort(a , a + n , greater <int> ()) ;
  if(n == 2){
    a[0] -= a[1] ;
    cout << a[0] << "\n" ;
    return ;
  }
  for(int i = 0 ; i < n  ; i++){
     if(a[i] < 0) break ;
     if(i & 1){
         Hridoy += a[i] ;
     }
     else Roy += a[i] ;
  }
  Roy -= Hridoy ;
  cout << Roy << "\n" ;

}
int main()
{
     __Heart__
     int t ; cin >> t ; while(t--) solve() ;
}

Information

Submit By
Type
Submission
Problem
P1208 C. Game on Integer
Language
C++17 (G++ 13.2.0)
Submit At
2025-06-29 19:56:01
Judged At
2025-06-29 19:56:01
Judged By
Score
60
Total Time
38ms
Peak Memory
2.07 MiB