/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 540.0 KiB
#2 Wrong Answer 53ms 556.0 KiB
#3 Wrong Answer 53ms 564.0 KiB

Code

#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
int main()
{
    ll tc;
    cin>>tc;
    while(tc--)
    {
        ll n;
        cin>>n;
        map<ll,ll>mp;
        vector<ll>v(n);
        for(int i=0;i<n;i++)
        {
            cin>>v[i]; mp[v[i]]++;
        }
        ll z=mp[0];
        ll o=mp[1];
        ll m=mp[-1];
        ll u=min(z/2,m);
        z-=u*2;
        m-=u;
        ll ans=0;
        ll x=min(z/2,o);
        z-=x*2;
        o-=x;
       ll y=min(m/2,o);
        ans+=y;
        m-=y*2;
        o-=y;
        ans+=(o/3);
        o=o%3;
        y=min(o/2,m);
        ans-=y;
        o-=y*2;
        m-=y;
        cout<<ans<<endl;
    }
}

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:50:11
Judged At
2025-01-02 14:50:11
Judged By
Score
1
Total Time
53ms
Peak Memory
564.0 KiB