/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 332.0 KiB
#2 Wrong Answer 32ms 552.0 KiB
#3 Wrong Answer 32ms 540.0 KiB

Code

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

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

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

        vector<int> A(N);
        int count_neg = 0, count_zero = 0, count_pos = 0;

        for (int i = 0; i < N; ++i) {
            cin >> A[i];
            if (A[i] == -1) count_neg++;
            else if (A[i] == 0) count_zero++;
            else if (A[i] == 1) count_pos++;
        }

        int score = 0;

        int groups_with_neg = min(count_neg / 2, count_pos);
        score += groups_with_neg;
        count_neg -= groups_with_neg * 2;
        count_pos -= groups_with_neg;

        score += count_pos / 3;
        count_pos %= 3;

        if (count_neg > 0 && count_pos >= 2) {
            score += -1;
        }

        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 16:59:50
Judged At
2025-01-02 16:59:50
Judged By
Score
1
Total Time
32ms
Peak Memory
552.0 KiB