113932024-09-05 13:58:01GervidSzemetessorcpp17Wrong answer 17/100142ms18112 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';
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted2ms360 KiB
2Accepted3ms500 KiB
subtask217/17
3Accepted3ms788 KiB
4Accepted3ms512 KiB
5Accepted3ms632 KiB
6Accepted3ms536 KiB
7Accepted3ms528 KiB
8Accepted3ms528 KiB
9Accepted3ms504 KiB
10Accepted3ms436 KiB
11Accepted2ms376 KiB
subtask30/25
12Wrong answer46ms3688 KiB
13Wrong answer48ms3944 KiB
14Wrong answer52ms4292 KiB
15Wrong answer56ms4528 KiB
16Wrong answer61ms5060 KiB
17Wrong answer97ms11152 KiB
18Wrong answer140ms17948 KiB
19Wrong answer142ms18112 KiB
20Wrong answer118ms18024 KiB
subtask40/20
21Accepted54ms4456 KiB
22Wrong answer71ms6536 KiB
23Accepted54ms4596 KiB
24Wrong answer68ms5776 KiB
25Accepted57ms4596 KiB
26Wrong answer93ms10056 KiB
27Wrong answer128ms15260 KiB
28Wrong answer128ms15372 KiB
29Wrong answer130ms15264 KiB
30Wrong answer119ms14440 KiB
subtask50/38
31Accepted3ms376 KiB
32Accepted3ms616 KiB
33Accepted3ms632 KiB
34Accepted3ms360 KiB
35Wrong answer7ms980 KiB
36Wrong answer54ms4584 KiB
37Wrong answer118ms13856 KiB
38Wrong answer115ms13608 KiB
39Wrong answer119ms14028 KiB
40Wrong answer129ms14888 KiB
41Wrong answer127ms15592 KiB
42Wrong answer118ms15372 KiB