61712023-11-05 11:58:06GervidSzemetessorcpp17Wrong answer 17/100244ms8036 KiB
#include <iostream>
#include <vector>

using namespace std;

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

    vector<int> cap(n);

    for (i = 0; i < n; i++)
    {
        cin >> cap[i];
    }

    vector<int> bins(n);

    pair<int, int> current;

    for (i = 0; i < k; i++)
    {
        cin >> current.first >> current.second;

        if (bins[current.first] + current.second > cap[current.first])
        {
            out += cap[current.first] - bins[current.first];
            bins[current.first] = current.second;
        }
        else
        {
            bins[current.first] += current.second;
        }
    }

    for (i = 0; i < n; i++)
    {
        if (bins[i])
        {
            out += cap[i] - bins[i];
        }
    }

    cout << out;
}
//5 7
//66 73 68 79 78
//2 50
//3 69
//0 1
//2 20
//4 12
//1 44
//3 11
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1808 KiB
2Accepted3ms2056 KiB
subtask217/17
3Accepted2ms2152 KiB
4Accepted2ms2272 KiB
5Accepted2ms2484 KiB
6Accepted3ms2700 KiB
7Accepted3ms2908 KiB
8Accepted2ms3024 KiB
9Accepted2ms3024 KiB
10Accepted3ms3156 KiB
11Accepted2ms3232 KiB
subtask30/25
12Wrong answer118ms3236 KiB
13Wrong answer119ms3348 KiB
14Wrong answer131ms3436 KiB
15Wrong answer136ms3688 KiB
16Wrong answer149ms3912 KiB
17Wrong answer194ms5236 KiB
18Wrong answer241ms7136 KiB
19Wrong answer240ms7264 KiB
20Wrong answer240ms7204 KiB
subtask40/20
21Accepted123ms4180 KiB
22Wrong answer144ms4804 KiB
23Accepted125ms4176 KiB
24Wrong answer146ms4720 KiB
25Accepted131ms4532 KiB
26Wrong answer190ms5876 KiB
27Wrong answer238ms7216 KiB
28Wrong answer238ms7500 KiB
29Wrong answer238ms7580 KiB
30Wrong answer211ms7556 KiB
subtask50/38
31Accepted3ms4736 KiB
32Accepted3ms4832 KiB
33Accepted3ms4864 KiB
34Accepted3ms4876 KiB
35Wrong answer14ms4840 KiB
36Wrong answer136ms4812 KiB
37Wrong answer244ms7820 KiB
38Wrong answer244ms8036 KiB
39Wrong answer244ms7956 KiB
40Wrong answer244ms8020 KiB
41Wrong answer244ms7960 KiB
42Wrong answer243ms8024 KiB