/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 448.0 KiB
#2 Wrong Answer 11ms 576.0 KiB
#3 Wrong Answer 13ms 568.0 KiB

Code

/* 
*   @author:- SYEDA SADIATUL JANNAT TUSHI
*   date & time :2025-01-02 20:29:39
*   BANGLADESH , SYLHET. 
*/

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

#define endl          '\n'
#define ll            long long
#define vi            vector<ll>
#define pii           pair<ll,ll>
#define vii           vector<pii>
#define sz(x)         (int)x.size()
#define be(x)         x.begin(), x.end()
#define srt(v)         sort(v.begin(),v.end())
#define rsrt(v)        sort(v.rbegin(),v.rend())
#define fl(i, a, b)   for(ll i = (a); i < (b); i++)
#define print(v)      for(auto e:v) cout<<e<<" "; cout<<endl;
#define InShaAllah    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

void solve() {
    ll n;
    cin>> n;

    vi a(n);

    ll cnt1=0,cnt0=0,cntm=0;

    fl(i,0,n){
        cin>> a[i];
        if(a[i]==1)cnt1++;
        else if(a[i]==0)cnt0++;
        else{cntm++;}
    }

    ll ans=0;

    ll p=cntm/2;
    ll t1= min(p,cnt1);
    ans+=t1;
    cntm-=2*t1;
    cnt1-=t1;

    ll t2 = cnt1/3;
    ll rem = cnt1%3;
    ans+=t2;

    if(cnt1==2 && cntm==1){
        ans+=-1;
        cnt1=0;
        cntm=0;
    }

    cout<< ans <<endl;

}

int main() {
    InShaAllah
    ll t = 1;
    cin >> t;

    while (t--) {
        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 15:46:53
Judged At
2025-01-02 15:46:53
Judged By
Score
1
Total Time
13ms
Peak Memory
576.0 KiB