11393 | 2024-09-05 13:58:01 | Gervid | Szemetessor | cpp17 | Wrong answer 17/100 | 142ms | 18112 KiB |
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <limits.h>
#include <algorithm>
#include <math.h>
using namespace std;
int main()
{
iostream::sync_with_stdio(0);
cin.tie(0);
int n, k, i, t, q, j;
cin >> n >> k;
vector<int> cap(n), current(n);
for (i = 0; i < n; i++)
{
cin >> cap[i];
}
vector<vector<int>> trash(n);
for (i = 0; i < k; i++)
{
cin >> t >> q;
trash[t].push_back(q);
}
int ans = 0;
for (i = 0; i < n; i++)
{
for (j = 0; j < trash[i].size(); j++)
{
if (j == trash[i].size() - 1)
{
ans += cap[i] - current[i] - trash[i][j];
}
else
{
if (cap[i] < current[i] + trash[i][j] + trash[i][j+1])
{
ans += cap[i] - current[i] - trash[i][j];
current[i] = 0;
}
else
{
current[i] += trash[i][j];
}
}
}
}
cout << ans << '\n';
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 2ms | 360 KiB | ||||
2 | Accepted | 3ms | 500 KiB | ||||
subtask2 | 17/17 | ||||||
3 | Accepted | 3ms | 788 KiB | ||||
4 | Accepted | 3ms | 512 KiB | ||||
5 | Accepted | 3ms | 632 KiB | ||||
6 | Accepted | 3ms | 536 KiB | ||||
7 | Accepted | 3ms | 528 KiB | ||||
8 | Accepted | 3ms | 528 KiB | ||||
9 | Accepted | 3ms | 504 KiB | ||||
10 | Accepted | 3ms | 436 KiB | ||||
11 | Accepted | 2ms | 376 KiB | ||||
subtask3 | 0/25 | ||||||
12 | Wrong answer | 46ms | 3688 KiB | ||||
13 | Wrong answer | 48ms | 3944 KiB | ||||
14 | Wrong answer | 52ms | 4292 KiB | ||||
15 | Wrong answer | 56ms | 4528 KiB | ||||
16 | Wrong answer | 61ms | 5060 KiB | ||||
17 | Wrong answer | 97ms | 11152 KiB | ||||
18 | Wrong answer | 140ms | 17948 KiB | ||||
19 | Wrong answer | 142ms | 18112 KiB | ||||
20 | Wrong answer | 118ms | 18024 KiB | ||||
subtask4 | 0/20 | ||||||
21 | Accepted | 54ms | 4456 KiB | ||||
22 | Wrong answer | 71ms | 6536 KiB | ||||
23 | Accepted | 54ms | 4596 KiB | ||||
24 | Wrong answer | 68ms | 5776 KiB | ||||
25 | Accepted | 57ms | 4596 KiB | ||||
26 | Wrong answer | 93ms | 10056 KiB | ||||
27 | Wrong answer | 128ms | 15260 KiB | ||||
28 | Wrong answer | 128ms | 15372 KiB | ||||
29 | Wrong answer | 130ms | 15264 KiB | ||||
30 | Wrong answer | 119ms | 14440 KiB | ||||
subtask5 | 0/38 | ||||||
31 | Accepted | 3ms | 376 KiB | ||||
32 | Accepted | 3ms | 616 KiB | ||||
33 | Accepted | 3ms | 632 KiB | ||||
34 | Accepted | 3ms | 360 KiB | ||||
35 | Wrong answer | 7ms | 980 KiB | ||||
36 | Wrong answer | 54ms | 4584 KiB | ||||
37 | Wrong answer | 118ms | 13856 KiB | ||||
38 | Wrong answer | 115ms | 13608 KiB | ||||
39 | Wrong answer | 119ms | 14028 KiB | ||||
40 | Wrong answer | 129ms | 14888 KiB | ||||
41 | Wrong answer | 127ms | 15592 KiB | ||||
42 | Wrong answer | 118ms | 15372 KiB |