/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 1ms 764.0 KiB
#3 Accepted 1ms 764.0 KiB
#4 Accepted 1ms 532.0 KiB
#5 Accepted 34ms 532.0 KiB
#6 Accepted 20ms 532.0 KiB
#7 Accepted 41ms 1.27 MiB
#8 Accepted 104ms 1.285 MiB
#9 Accepted 105ms 1.289 MiB
#10 Accepted 98ms 1.066 MiB
#11 Wrong Answer 52ms 532.0 KiB
#12 Wrong Answer 45ms 764.0 KiB

Code

#include<bits/stdc++.h>
using namespace std;
// #define int             long long
#define pb              push_back
#define endl            '\n'
#define debug           cout<<"HERE"<<endl;
#define ff              first
#define ss              second
void edm()
{
    ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
}
void solve()
{
    int n;cin>>n;
    int arr[n];
    int pos=0;
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
        if(arr[i]>0)pos++;
    }
    int ans=0;
    sort(arr,arr+n);
    int now=1;
    for(int i=n-1;i>=0;i--)
    {
        if(arr[i]<=0)break;
        if(now)
        {
            ans = ans + arr[i];
            now=0;
        }
        else
        {
            ans = ans - arr[i];
            now=1;
        }
    }
    cout<<ans<<endl;
}
signed main()
{
    //edm();
    int t = 1;
    cin>>t;
    for(int i=1;i<=t;i++)
    {
        ///cout<<"Case "<<i<<": ";
        solve();
    }
} 

Information

Submit By
Type
Submission
Problem
P1208 C. Game on Integer
Contest
Educational Round 1
Language
C++17 (G++ 13.2.0)
Submit At
2025-07-14 16:13:07
Judged At
2025-07-14 16:13:07
Judged By
Score
60
Total Time
105ms
Peak Memory
1.289 MiB