Submission #1871201


Source Code Expand

#include <algorithm>
#include <cctype>
#include <complex>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::to_string;
using std::vector;
using std::set;
using std::queue;
using std::priority_queue;

using std::min;
using std::max;
using std::sort;
using std::abs;

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

    vector<int> a(1e5 + 1);

    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        a[x - 1]++;
    }

    int l = 0, r = 1e5;
    while(l < r){
        while(l < n && a[l] <= 1){
            l++;
        }
        while(r >= 0 && a[r] <= 1){
            r--;
        }
        if(l >= r){
            break;
        }
        a[l]--;
        a[r]--;
    }

    if(l == r && a[l] > 0){
        while(a[l] >= 3){
            a[l] -= 2;
        }
        if(a[l] == 2){
            a[l] = 0;
        }
    }

    int cnt = 0;
    for(int i = 0; i <= 1e5; i++){
        if(a[i] == 0){
            continue;
        }
        cnt++;
        // cout << i << " : " << a[i] << endl;
    }
    cout << cnt << endl;
    return 0;
}

Submission Info

Submission Time
Task D - Card Eater
User somq14
Language C++14 (Clang 3.8.0)
Score 0
Code Size 1260 Byte
Status WA
Exec Time 80 ms
Memory 640 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 400
Status
AC × 2
AC × 13
WA × 4
Set Name Test Cases
Sample 00_example_01.txt, 00_example_02.txt
All 00_example_01.txt, 00_example_02.txt, 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt
Case Name Status Exec Time Memory
00_example_01.txt AC 1 ms 640 KB
00_example_02.txt AC 1 ms 640 KB
01.txt WA 1 ms 640 KB
02.txt WA 6 ms 640 KB
03.txt AC 2 ms 640 KB
04.txt WA 2 ms 640 KB
05.txt WA 1 ms 640 KB
06.txt AC 80 ms 640 KB
07.txt AC 80 ms 640 KB
08.txt AC 79 ms 640 KB
09.txt AC 78 ms 640 KB
10.txt AC 80 ms 640 KB
11.txt AC 80 ms 640 KB
12.txt AC 79 ms 640 KB
13.txt AC 80 ms 640 KB
14.txt AC 77 ms 640 KB
15.txt AC 76 ms 640 KB