/ SeriousOJ /

Record Detail

Wrong Answer


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

Code

#include <bits/stdc++.h>
using namespace std;
//Speed
#define Code ios_base::sync_with_stdio(false);
#define By cin.tie(NULL);
#define Shoriful cout.tie(NULL);
template<typename T>  istream& operator>>(istream& is,  vector<T> &v){for (auto& i : v) is >> i;   return is;}
template<typename T>  ostream& operator<<(ostream& os,  vector<T>  v){for (auto& i : v) os << i << ' '; return os;}
#define ff first
#define ss second

#define pb push_back
#define mp make_pair
#define sz size()

#define all(v) v.begin(),v.end()
#define rall(v) v.end(),v.begin()

#define fl(i,n) for(int i=0;i<n;i++)
#define rl(i,m,n) for(int i=n;i>=m;i--)


#define py cout<<"YES\n";
#define pn cout<<"NO\n";

#define nl  '\n' ;

typedef long long ll ;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<int,int> pi;
typedef map<int,int> mi;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<set<int>> vset ;
typedef map<ll,ll> mll;

 
//code here 

void solve(){
         
         int n ;  cin >> n ; 
         
         vi v(n) ;  cin>>v ; 
         
         int a= count(all(v),1) ; 
         int b=count(all(v),0) ; 
         
         int c= count(all(v),-1) ; 
         
         
         int ans=0 ; 
         
         ans+=(a/3) ; 
         a%=3;
         
         int d=c/2 ;
         
         int e=min(d,a) ;
         ans+=e;
         
         c-=2*e ;
         a-=e;
         ans-=(c/3) ;
         
         cout<<ans<<nl;
   
}

int main()
{
        
        Code By Shoriful
     // ll t=1 ;
      ll t ;   cin >> t ; 
      
      fl(i,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:30:39
Judged At
2025-01-02 15:30:39
Judged By
Score
1
Total Time
12ms
Peak Memory
576.0 KiB