/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 480.0 KiB
#2 Accepted 2ms 512.0 KiB
#3 Accepted 3ms 524.0 KiB
#4 Accepted 3ms 576.0 KiB
#5 Accepted 3ms 520.0 KiB
#6 Accepted 2ms 780.0 KiB
#7 Accepted 2ms 328.0 KiB

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