/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Wrong Answer 33ms 808.0 KiB
#3 Wrong Answer 34ms 540.0 KiB

Code

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

int musa(vector<int>& A) 
{
    int cnt_n = 0, z = 0, o = 0;

    for (int x : A) 
    {
        if (x == -1) cnt_n++;
        else if (x == 0) z++;
        else if (x == 1) o++;
    }

    int score = 0;
    int tr = o / 3;
    score += tr;
    o %= 3;


    int pn = min(cnt_n / 2, o);
    score += pn; 
    cnt_n -= pn * 2;
    o -= pn;


    score += (cnt_n / 3) * -1;
    return score;
}

int main() 
{
    int T;
    cin >> T;

    while (T--) 
    {
        int N;
        cin >> N;

        vector<int> A(N);
        for (int i = 0; i < N; i++)
        {
            cin >> A[i];
        }

        cout << musa(A) << endl;
    }

    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:50:57
Judged At
2025-01-02 15:50:57
Judged By
Score
1
Total Time
34ms
Peak Memory
808.0 KiB