Submission #5444522


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;

int main(void) {
    int Alice_score = 0;
    int Bob_score = 0;
    bool turn = false; // Alice
    int N = -1;
    cin >> N;
    vector<int> a;
    for (int i=0; i<N; i++) {
        int t;
        cin >> t;
        a.push_back(t); 
    }

    // sort
    for (int i=0; i<N; i++) {
        for (int j=0; j<N-1; j++) {
            int temp;
            if(a[j] < a[j+1]) {
                temp = a[j];
                a[j] = a[j+1];
                a[j+1] = temp;
            }
        }
    }


    for (int i=0; i<N; i++) {
        if(turn == false) { // Alice
            Alice_score += a[i];
        } else {
            Bob_score += a[i];
        }
        turn = (!turn);
    }

    cout << Alice_score - Bob_score << endl;
    

    return 0;
}

Submission Info

Submission Time
Task A - 高橋君とホテルイージー / Tak and Hotels (ABC Edit)
User Mui
Language C++14 (GCC 5.4.1)
Score 0
Code Size 840 Byte
Status
Exec Time 67 ms
Memory 384 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 example_01.txt, example_02.txt
All 0 / 100 example_01.txt, example_02.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt
Case Name Status Exec Time Memory
example_01.txt 1 ms 256 KB
example_02.txt 1 ms 256 KB
subtask1_01.txt 1 ms 256 KB
subtask1_02.txt 1 ms 256 KB
subtask1_03.txt 66 ms 384 KB
subtask1_04.txt 1 ms 256 KB
subtask1_05.txt 67 ms 384 KB
subtask1_06.txt 67 ms 384 KB
subtask1_07.txt 66 ms 384 KB
subtask1_08.txt 2 ms 256 KB