/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Wrong Answer 38ms 560.0 KiB
#3 Wrong Answer 42ms 532.0 KiB

Code

#include<bits/stdc++.h>
using namespace std;
#define int             long long
#define pb              push_back
#define endl            '\n'
void edm()
{
    ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
}
void solve()
{
    int n;cin>>n;
    int one=0,zero=0,mn=0;
    for(int i=0;i<n;i++)
    {
        int x;cin>>x;
        if(x==1)one++;
        else if(x==0)zero++;
        else mn++;
    }
    int ans=0;
    ans = ans + min(one,mn/2);
    one = one - ans;
    mn = mn - 2*ans;
    if(one && zero && mn)
    {
        one--;
        zero--;
        mn--;
    }
    ans = ans + one/3;
    one = one%3;
    int xt = min(2*zero,mn);
    mn = mn - xt + one;
    zero = zero - xt;
    ans = ans - mn/3;
    cout<<ans<<endl;
}
int32_t main()
{
    //edm();
    int t = 1;
    cin>>t;
    for(int i=1;i<=t;i++)
    {
        solve();
    }
} 

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:25:01
Judged At
2025-01-02 15:25:01
Judged By
Score
1
Total Time
42ms
Peak Memory
560.0 KiB