Accepted
Code
#include<bits/stdc++.h>
using namespace std;
const long long M=3e5+10,MOD=1000000007;
typedef long long ll;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int t=1;
cin>>t;
while(t--){
int n;
cin>>n;
vector<int>a(n);
for(auto &i:a)cin>>i;
int sum=accumulate(a.begin(),a.end(),0);
if(sum%3==0){
cout<<n<<"\n";
continue;
}
int ans=2;
for(int i=0;i<n;i++){
if((sum-a[i])%3==0){
ans=1;
break;
}
}
cout<<n-ans<<"\n";
}
return 0;
}
Information
- Submit By
- Type
- Submission
- Problem
- P1013 Divisible by 3
- Language
- C++20 (G++ 13.2.0)
- Submit At
- 2024-03-06 09:48:37
- Judged At
- 2024-11-11 03:42:54
- Judged By
- Score
- 100
- Total Time
- 3ms
- Peak Memory
- 780.0 KiB