/ 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 Wrong Answer 14ms 532.0 KiB
#6 Wrong Answer 10ms 568.0 KiB

Code

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define yes cout<<"YES"<<endl;
#define no cout<<"NO"<<endl;


int main ()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int t; cin>>t;
    while(t--)
    {
        int n; cin>>n;
        vector<int>v(n);
        for(int i=0; i<n; i++)
            cin>>v[i];


        int cnt=0;
        sort(v.rbegin(),v.rend());
        if(n>=3)
        {
        for(int i=0; i<=2; i++)
        {
           if(v[i]>0)
            cnt++;
        }
        }

       // cout<<cnt<<endl;
       if(cnt>=3)
            cout<<v[0]-v[1]+v[2]<<endl;
        else
            cout<<v[0]-v[1]<<endl;

//        if(n==2)
//            cout<<v[0]-v[1]<<endl;
//        if(pos_count==n || pos_count>=3)
//        {
//            cout<<v[0]-v[1]+v[2]<<endl;
//        }
//
//        else if(neg_count==n)
//        {
//            cout<<v[0]-v[1]<<endl;
//        }
//        else
//            cout<<v[0]-v[1]<<endl;





    }


    return 0;
}

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:59:15
Judged At
2025-07-14 16:59:15
Judged By
Score
5
Total Time
14ms
Peak Memory
568.0 KiB