/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Wrong Answer 28ms 532.0 KiB
#3 Wrong Answer 11ms 532.0 KiB

Code

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int T;
    cin >> T;

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

        int neg = 0, zero = 0, pos = 0;
        for (int i = 0; i < N; ++i) {
            int x;
            cin >> x;
            if (x == -1) neg++;
            else if (x == 0) zero++;
            else pos++;
        }

        int score = 0;

        int trip_pos = pos / 3;
        score += trip_pos;
        pos -= trip_pos * 3;

        int trip_neg_pos = min(neg / 2, pos);
        score += trip_neg_pos;
        neg -= trip_neg_pos * 2;
        pos -= trip_neg_pos;

        int trip_neg = neg / 3;
        score -= trip_neg;
        neg -= trip_neg * 3;

        cout << score << "\n";
    }

    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:12:23
Judged At
2025-01-02 16:12:23
Judged By
Score
1
Total Time
28ms
Peak Memory
532.0 KiB