62322023-11-08 12:07:13GhostSzemetessorcpp17Wrong answer 17/100246ms7816 KiB
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int n, k, capacity, type, amount, i, out = 0;
    cin >> n >> k;

    vector<pair<int, int>> trash(n, { 0,0 });
    for (i = 0; i < n; i++) {
        cin >> trash[i].second;
    }

    for (i = 0; i < k; i++) {
        cin >> type >> amount;
        if (trash[type].first + amount < trash[type].second) {
            trash[type].first += amount;
        }
        else if (trash[type].first + amount == trash[type].second) {
            trash[type].first = 0;
        }
        else {
            out += trash[type].second - trash[type].first;
            trash[type].first = amount;
        }
    }
    for (i = 0; i < n; i++) {
        if (trash[i].first > 0) {
            out += trash[i].second - trash[i].first;
        }
    }

    cout << out;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1680 KiB
2Accepted2ms1848 KiB
subtask217/17
3Accepted2ms1928 KiB
4Accepted2ms2056 KiB
5Accepted2ms2148 KiB
6Accepted3ms2272 KiB
7Accepted3ms2512 KiB
8Accepted3ms2696 KiB
9Accepted3ms2936 KiB
10Accepted2ms2992 KiB
11Accepted2ms3120 KiB
subtask30/25
12Wrong answer118ms3364 KiB
13Wrong answer118ms3448 KiB
14Wrong answer130ms3732 KiB
15Wrong answer136ms3664 KiB
16Wrong answer148ms3552 KiB
17Wrong answer194ms5004 KiB
18Wrong answer246ms6760 KiB
19Wrong answer243ms6944 KiB
20Wrong answer240ms7140 KiB
subtask40/20
21Accepted123ms4144 KiB
22Wrong answer143ms4816 KiB
23Accepted125ms4372 KiB
24Wrong answer143ms4308 KiB
25Accepted131ms4492 KiB
26Wrong answer190ms5816 KiB
27Wrong answer234ms7492 KiB
28Wrong answer237ms7656 KiB
29Wrong answer238ms7696 KiB
30Wrong answer217ms7696 KiB
subtask50/38
31Accepted3ms4672 KiB
32Accepted3ms4552 KiB
33Accepted3ms4672 KiB
34Accepted3ms4548 KiB
35Wrong answer14ms4624 KiB
36Wrong answer136ms4604 KiB
37Wrong answer243ms7768 KiB
38Wrong answer246ms7712 KiB
39Wrong answer244ms7668 KiB
40Wrong answer241ms7816 KiB
41Wrong answer246ms7668 KiB
42Wrong answer243ms7672 KiB