/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Wrong Answer 4ms 540.0 KiB
#3 Wrong Answer 5ms 584.0 KiB

Code

#include<bits/stdc++.h>
#define ll long long
#define endl "\n"
using namespace std;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int t,a,b,x;   cin >> t; 
    while(t--){
        cin >> a;
        //int temp = a;
        map<int,int>m;
        bool zero = false;
        for(int i = 0;i<a;i++){
            cin >> x;
            //cout << x << " ";
            m[x]++;
            if(x==0){
                zero = true;
                cout << 0 << endl;
                break;
            }
        }
        if(zero)    continue;
        else if(a == 6 && m[1]==3 && m[-1]==3) cout << 0 << endl;
        else{
            //cout << m[1] << " " << m[-1] << endl;
            if(m[-1]==0 || m[1]==0)    cout << (m[1] + (-1)*m[-1])/3 << endl;
            else if(m[-1]%2==0 && m[-1]<=((a/3)*2))    cout << a/3 << endl;
            else if(m[-1]%2==0 && m[-1]>((a/3)*2))    cout << m[-1]/3 - a/3 << endl;
            else if(m[-1]%2!=0 && m[-1]<=((a/3)*2+1))    cout << a/3 - 1 << endl;
            else if(m[-1]%2!=0 && m[-1]>((a/3)*2+1))    cout << m[-1]/3 - a/3 << endl;
        }
    }
  return 0;
}
    

Information

Submit By
Type
Submission
Problem
P1152 Special Array
Language
C++17 (G++ 13.2.0)
Submit At
2025-01-03 02:11:49
Judged At
2025-01-03 02:11:49
Judged By
Score
1
Total Time
5ms
Peak Memory
584.0 KiB