/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 332.0 KiB
#2 Wrong Answer 11ms 564.0 KiB
#3 Wrong Answer 14ms 572.0 KiB

Code

// Author: Mushfiq R.
#include <bits/stdc++.h>
#define endl "\n"
#define ll long long
#define ld long double
#define ull unsigned long long
#define vsort(v) sort(v.begin(), v.end())
#define rsort(v) sort(v.begin(), v.end(), greater<int>())
#define fastIO() (ios_base::sync_with_stdio(false), cin.tie(NULL));
using namespace std;

int main()
{
    fastIO();
    int t = 1;
    cin >> t;
    while (t--)
    {
        int n, score = 0;
        cin >> n;

        int zero = 0, plus = 0, minus = 0;
        for (int i = 0; i < n; i++)
        {
            int x;
            cin >> x;

            if (x == 0)
                zero++;
            else if (x == 1)
                plus++;
            else if (x == -1)
                minus++;
        }

        while (plus >= 3)
        {
            score += 1;
            plus -= 3;
        }

        while (minus >= 2 && plus >= 1)
        {
            score += 1;
            minus -= 2;
            plus -= 1;
        }

        while (minus >= 3)
        {
            score -= 1;
            minus -= 3;
        }

        cout << score << 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:35:49
Judged At
2025-01-02 15:35:49
Judged By
Score
1
Total Time
14ms
Peak Memory
572.0 KiB