Wrong Answer
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;
map<int,int>m;
while(a--){
cin >> x;
m[x]++;
}
if(m[0] || m[1]==3 && m[-1]==3) cout << 0 << endl;
else{
int s=0;
if(m[-1]%2!=0) cout << a/3 - max(1,m[-1]/3) << endl;
else if(m[-1]%2==0 && m[1]!=0) cout << a/3 << endl;
else cout << -a/3 << endl;
}
}
return 0;
}
Information
- Submit By
- Type
- Submission
- Problem
- P1152 Special Array
- Contest
- Happy New Year 2025
- Language
- C++17 (G++ 13.2.0)
- Submit At
- 2025-01-02 15:28:49
- Judged At
- 2025-01-02 15:28:49
- Judged By
- Score
- 1
- Total Time
- 14ms
- Peak Memory
- 576.0 KiB