11801 | 2024-11-11 17:25:03 | MCDave | Szemetessor | cpp17 | Accepted 100/100 | 250ms | 2036 KiB |
#include <iostream>
#include <vector>
using namespace std;
int main()
{
int n, m, i, c, plus, number;
cin >> n >> m;
vector<int> cap(n), current(n, 0);
long long out = 0;
for (i = 0; i < n; i++)
{
cin >> cap[i];
}
for (i = 0; i < m; i++)
{
cin >> number >> plus;
if (current[number] + plus <= cap[number])
{
current[number] += plus;
}
else
{
out += cap[number] - current[number];
current[number] = plus;
}
}
for (i = 0; i < n; i++)
{
if (current[i] != 0)
{
out += cap[i] - current[i];
}
}
cout << out;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 1ms | 500 KiB | ||||
2 | Accepted | 1ms | 320 KiB | ||||
subtask2 | 17/17 | ||||||
3 | Accepted | 1ms | 320 KiB | ||||
4 | Accepted | 1ms | 320 KiB | ||||
5 | Accepted | 1ms | 320 KiB | ||||
6 | Accepted | 1ms | 320 KiB | ||||
7 | Accepted | 1ms | 320 KiB | ||||
8 | Accepted | 1ms | 332 KiB | ||||
9 | Accepted | 1ms | 320 KiB | ||||
10 | Accepted | 1ms | 512 KiB | ||||
11 | Accepted | 1ms | 320 KiB | ||||
subtask3 | 25/25 | ||||||
12 | Accepted | 118ms | 404 KiB | ||||
13 | Accepted | 118ms | 404 KiB | ||||
14 | Accepted | 133ms | 508 KiB | ||||
15 | Accepted | 137ms | 424 KiB | ||||
16 | Accepted | 149ms | 740 KiB | ||||
17 | Accepted | 195ms | 1196 KiB | ||||
18 | Accepted | 245ms | 1848 KiB | ||||
19 | Accepted | 245ms | 1848 KiB | ||||
20 | Accepted | 245ms | 1848 KiB | ||||
subtask4 | 20/20 | ||||||
21 | Accepted | 122ms | 320 KiB | ||||
22 | Accepted | 143ms | 568 KiB | ||||
23 | Accepted | 123ms | 476 KiB | ||||
24 | Accepted | 146ms | 568 KiB | ||||
25 | Accepted | 142ms | 484 KiB | ||||
26 | Accepted | 193ms | 1080 KiB | ||||
27 | Accepted | 239ms | 1904 KiB | ||||
28 | Accepted | 239ms | 1956 KiB | ||||
29 | Accepted | 243ms | 2036 KiB | ||||
30 | Accepted | 214ms | 1848 KiB | ||||
subtask5 | 38/38 | ||||||
31 | Accepted | 1ms | 320 KiB | ||||
32 | Accepted | 1ms | 320 KiB | ||||
33 | Accepted | 2ms | 588 KiB | ||||
34 | Accepted | 2ms | 512 KiB | ||||
35 | Accepted | 12ms | 480 KiB | ||||
36 | Accepted | 137ms | 408 KiB | ||||
37 | Accepted | 246ms | 1984 KiB | ||||
38 | Accepted | 247ms | 2036 KiB | ||||
39 | Accepted | 246ms | 1852 KiB | ||||
40 | Accepted | 250ms | 1848 KiB | ||||
41 | Accepted | 246ms | 1848 KiB | ||||
42 | Accepted | 246ms | 1848 KiB |