AtCoder Grand Contest 018

Submission #5907446

Source codeソースコード

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

typedef long long ll;
typedef pair<int,int> P;

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

struct coin {
    int x,y,z;
    bool operator<(const coin& a) const {
        return x-y > a.x-a.y;
    }
};

int main() {
    int x,y,z;
    cin >> x >> y >> z;
    int n = x+y+z;
    vector<coin> a(n);
    priority_queue<int> que1,que2;
    for (int i = 0;i < n;++i) cin >> a[i].x >> a[i].y >> a[i].z;
    sort(a.begin(),a.end());
    ll ans = 0;
    for (int i = 0;i < x;++i) {
        ans += a[i].x;
        que1.push(a[i].z-a[i].x);
    }
    for (int i = x+z;i < n;++i) {
        ans += a[i].y;
        que2.push(a[i].z-a[i].y);
    }
    // cout << ans << endl;
    // for (int i = 0;i < n;++i) cout << a[i].x << " " << a[i].y << " " << a[i].z << endl;
    for (int i = x;i < x+z;++i) {
        ll u = que1.top()+a[i].x,v = que2.top()+a[i].y;
        if (u > a[i].z && u > v) {
            ans += u;
            que1.pop();
            que1.push(a[i].z-a[i].x);
        } else if (v > a[i].z && u <= v) {
            ans += v;
            que2.pop();
            que2.push(a[i].z-a[i].y);
        } else {
            ans += a[i].z;
        }
    }
    cout << ans << endl;
    return 0;
}

Submission

Task問題 C - Coins
User nameユーザ名 koikotya
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 WA
Score得点 0
Source lengthソースコード長 1592 Byte
File nameファイル名
Exec time実行時間 ms
Memory usageメモリ使用量 -

Test case

Set

Set name Score得点 / Max score Cases
Sample - sample_01.txt,sample_02.txt,sample_03.txt
All 0 / 800 sample_01.txt,sample_02.txt,sample_03.txt,sample_01.txt,sample_02.txt,sample_03.txt,subtask_1_01.txt,subtask_1_02.txt,subtask_1_03.txt,subtask_1_04.txt,subtask_1_05.txt,subtask_1_06.txt,subtask_1_07.txt,subtask_1_08.txt,subtask_1_09.txt,subtask_1_10.txt,subtask_1_11.txt,subtask_1_12.txt,subtask_1_13.txt,subtask_1_14.txt,subtask_1_15.txt,subtask_1_16.txt,subtask_1_17.txt,subtask_1_18.txt,subtask_1_19.txt,subtask_1_20.txt,subtask_1_21.txt,subtask_1_22.txt,subtask_1_23.txt,subtask_1_24.txt,subtask_1_25.txt,subtask_1_26.txt,subtask_1_27.txt,subtask_1_28.txt,subtask_1_29.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
sample_01.txt AC 1 ms 256 KB
sample_02.txt AC 1 ms 256 KB
sample_03.txt AC 1 ms 256 KB
subtask_1_01.txt AC 1 ms 256 KB
subtask_1_02.txt WA
subtask_1_03.txt AC 39 ms 640 KB
subtask_1_04.txt WA
subtask_1_05.txt WA
subtask_1_06.txt WA
subtask_1_07.txt AC 25 ms 640 KB
subtask_1_08.txt AC 90 ms 1408 KB
subtask_1_09.txt WA
subtask_1_10.txt WA
subtask_1_11.txt WA
subtask_1_12.txt AC 121 ms 2044 KB
subtask_1_13.txt WA
subtask_1_14.txt WA
subtask_1_15.txt WA
subtask_1_16.txt AC 103 ms 2064 KB
subtask_1_17.txt AC 104 ms 1792 KB
subtask_1_18.txt AC 107 ms 1664 KB
subtask_1_19.txt WA
subtask_1_20.txt WA
subtask_1_21.txt AC 121 ms 1792 KB
subtask_1_22.txt WA
subtask_1_23.txt AC 130 ms 1792 KB
subtask_1_24.txt WA
subtask_1_25.txt AC 103 ms 2052 KB
subtask_1_26.txt AC 108 ms 2044 KB
subtask_1_27.txt AC 107 ms 1792 KB
subtask_1_28.txt WA
subtask_1_29.txt AC 1 ms 256 KB