6235 | 2023-11-08 12:17:26 | EsVagy | Szemetessor | cpp17 | Accepted 100/100 | 256ms | 8332 KiB |
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <climits>
using namespace std;
int main()
{
int N, K;
cin >> N >> K;
vector<int> c;
vector<int> t;
long int cost = 0;
for (int i = 0; i < N; i++)
{
int next;
cin >> next;
c.push_back(next);
t.push_back(0);
}
for (int i = 0; i < K; i++)
{
int index, trash;
cin >> index >> trash;
long int newTrash = t[index] + trash;
if (newTrash > c[index])
{
cost += c[index] - t[index];
t[index] = trash;
}
else
{
t[index] += trash;
}
}
for (int i = 0; i < N; i++)
{
cost += t[i] == 0 ? 0 : c[i] - t[i];
}
cout << cost;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1816 KiB | ||||
2 | Accepted | 3ms | 2004 KiB | ||||
subtask2 | 17/17 | ||||||
3 | Accepted | 3ms | 2212 KiB | ||||
4 | Accepted | 3ms | 2428 KiB | ||||
5 | Accepted | 3ms | 2648 KiB | ||||
6 | Accepted | 3ms | 2848 KiB | ||||
7 | Accepted | 2ms | 2932 KiB | ||||
8 | Accepted | 3ms | 3064 KiB | ||||
9 | Accepted | 3ms | 3304 KiB | ||||
10 | Accepted | 2ms | 3276 KiB | ||||
11 | Accepted | 2ms | 3156 KiB | ||||
subtask3 | 25/25 | ||||||
12 | Accepted | 122ms | 3284 KiB | ||||
13 | Accepted | 120ms | 3412 KiB | ||||
14 | Accepted | 135ms | 3504 KiB | ||||
15 | Accepted | 141ms | 3796 KiB | ||||
16 | Accepted | 153ms | 4236 KiB | ||||
17 | Accepted | 202ms | 5868 KiB | ||||
18 | Accepted | 252ms | 7644 KiB | ||||
19 | Accepted | 252ms | 7832 KiB | ||||
20 | Accepted | 252ms | 7928 KiB | ||||
subtask4 | 20/20 | ||||||
21 | Accepted | 126ms | 4928 KiB | ||||
22 | Accepted | 148ms | 5496 KiB | ||||
23 | Accepted | 128ms | 5232 KiB | ||||
24 | Accepted | 150ms | 5476 KiB | ||||
25 | Accepted | 135ms | 5180 KiB | ||||
26 | Accepted | 197ms | 6724 KiB | ||||
27 | Accepted | 247ms | 8056 KiB | ||||
28 | Accepted | 248ms | 7992 KiB | ||||
29 | Accepted | 250ms | 8064 KiB | ||||
30 | Accepted | 217ms | 8332 KiB | ||||
subtask5 | 38/38 | ||||||
31 | Accepted | 3ms | 4948 KiB | ||||
32 | Accepted | 3ms | 4948 KiB | ||||
33 | Accepted | 3ms | 5060 KiB | ||||
34 | Accepted | 3ms | 4952 KiB | ||||
35 | Accepted | 14ms | 5352 KiB | ||||
36 | Accepted | 142ms | 4852 KiB | ||||
37 | Accepted | 256ms | 8192 KiB | ||||
38 | Accepted | 254ms | 8192 KiB | ||||
39 | Accepted | 256ms | 8200 KiB | ||||
40 | Accepted | 254ms | 8200 KiB | ||||
41 | Accepted | 254ms | 8288 KiB | ||||
42 | Accepted | 254ms | 8200 KiB |