/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Wrong Answer 11ms 532.0 KiB
#3 Wrong Answer 12ms 484.0 KiB

Code

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

#define endl '\n'
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

void solve(){
    int n;
    cin>>n;
    int cnt0=0,cnt1 =0, cntn1=0;
    for(int i=0; i<n; i++){
        int x;
        cin>>x;
        if(x==0) cnt0++;
        else if(x==1) cnt1++;
        else cntn1++;
    }

    int result = 0;
    int n1cnt = cntn1/2;
    result += min(n1cnt,cnt1);
    cnt1 -= result;
    cntn1 -= (2*result);

    int cnt11 = cnt1/3;
    result += cnt11;
    cnt1 %= 3;
    
    n1cnt = cntn1/2;
    int zac = min(n1cnt,cnt0);
    
    cntn1 -= 2*zac;
    cnt0 -= zac;

    if(cntn1){
        result -= (cntn1+cnt1)/3;
    }
    
    cout<<result<<endl;
}

signed main(){
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    optimize();

    ll t;
    cin>>t;
    for(ll i=1; i<=t; i++){
        solve();
    }
    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 14:56:35
Judged At
2025-01-02 14:56:35
Judged By
Score
1
Total Time
12ms
Peak Memory
532.0 KiB