/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Wrong Answer 40ms 556.0 KiB
#3 Wrong Answer 38ms 384.0 KiB

Code

#include <iostream>
#include <vector>
using namespace std;

int solve(int n, vector<int>& A) {
    int a = 0, b = 0, c = 0;

    for (int x : A) {
        if (x == -1) a++;
        else if (x == 0) b++;
        else c++;
    }

    int score = 0;
    int t1 = c / 3;
    score += t1;
    c %= 3;

    int t2 = min(c / 2, a);
    score -= t2;
    c -= t2 * 2;
    a -= t2;

    int t3 = a / 3;
    score -= t3;
    a %= 3;

    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 << solve(N, 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:06:07
Judged At
2025-01-02 15:06:07
Judged By
Score
1
Total Time
40ms
Peak Memory
556.0 KiB