/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 328.0 KiB
#2 Wrong Answer 20ms 568.0 KiB
#3 Wrong Answer 20ms 576.0 KiB

Code

#include <bits/stdc++.h>

#define CY cout << "YES\n";
#define CN cout << "NO\n";
#define Cy cout << "Yes\n";
#define Cn cout << "No\n";
#define all(x) (x).begin(), (x).end()
#define sz(s) ((int)((s).size()))
#define torad(x) (x) * ((2 * acos(0)) / 180.0)
#define vll vector<long long>
#define ite vector<long long>::iterator
typedef long long ll;
#define pb push_back
#define forr for (int i = 0; i < n; i++)
#define big(v) *max_element(all(v))
#define small(v) *min_element(all(v))
#define PI 2 * acos(0)
#define pob pop_back
# define    ff first
# define    ss second
const ll inf = 1e9 + 7;
#define vcin(a, n)             \
    vll a(n);                  \
    for (ll i = 0; i < n; i++) \
        cin >> a[i];
#define print(a)              \
    {                         \
        for (auto u : a)      \
            cout << u << " "; \
        cout << endl;         \
    }
#define adi(i, j, k) for (ll i = j; i < k; i++)
#define oda(i, j, k) for (ll i = j; i >= k; i--)
#define nothing                   \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);
using namespace std;
ll GCD(ll x, ll y)
{
    if (y == 0)
        return x;
    else
        return GCD(y, x % y);
}
ll LCM(ll x, ll y)
{
    return (x * y / (GCD(x, y)));
}
ll suum (vll z, ll n) 
 { 
ll sum = 0, i;
  
for(i=0;i<n;i++)
 { 
sum += z[i];
  
}
  
return sum;

}


/*void OJ()
{
#ifndef ONLINE_JUDGE
    freopen("H:\\Desktop\\cp\\input.txt", "r", stdin);
    freopen("H:\\Desktop\\cp\\output.txt", "w+", stdout);
#endif
}
*/	
#define lo(a,n) lower_bound(all(a),n)-a.begin()
#define up(a,n) upper_bound(all(a),n)-a.begin()
#define lq "\n"
long long power(long long b, long long e) {
    long long result = 1;
    for (long long i = 1; i <= e; i++) {
        if (result > 1e18 / b) 
            return -1;
        result *= b;
    }
    return result;
}
int main()
{
nothing

ll tc,n,m,x,ans,sum,f,i,j,y,z,mx,k;
string s,t;
map<ll,ll>mp,mp1;
	set<ll>st,st1;
cin>>tc;
while(tc--)
{
	cin>>n;
	vcin(a,n);
		ll one=0,minus=0,zero=0;
		for(i=0;i<n;i++)
		{
			if(a[i]==1)
			one++;
			else if(a[i]==-1)
			minus++;
			else
			zero++;
		}
		sum=0;
		x=one/3;
		sum+=x;
		one=one%3;
		x=minus/2;
		y=min(x,zero);
		zero-=y;
		minus=minus%2;
		if(zero==0&&minus!=0)
		sum--;
		cout<<sum<<lq;
}
	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:52:22
Judged At
2025-01-02 14:52:22
Judged By
Score
1
Total Time
20ms
Peak Memory
576.0 KiB