118002024-11-11 17:22:58MCDaveSzemetessorcpp17Wrong answer 17/100250ms1988 KiB
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int n, m, i, c, plus, number, out = 0;
    cin >> n >> m;
	vector<int> cap(n), current(n, 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;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted1ms320 KiB
2Accepted1ms508 KiB
subtask217/17
3Accepted1ms320 KiB
4Accepted1ms320 KiB
5Accepted1ms320 KiB
6Accepted1ms320 KiB
7Accepted1ms396 KiB
8Accepted1ms320 KiB
9Accepted1ms320 KiB
10Accepted1ms320 KiB
11Accepted1ms320 KiB
subtask30/25
12Wrong answer118ms404 KiB
13Wrong answer116ms408 KiB
14Wrong answer131ms412 KiB
15Wrong answer136ms508 KiB
16Wrong answer150ms472 KiB
17Wrong answer200ms1080 KiB
18Wrong answer248ms1988 KiB
19Wrong answer248ms1884 KiB
20Wrong answer246ms1848 KiB
subtask40/20
21Accepted122ms484 KiB
22Wrong answer144ms568 KiB
23Accepted123ms320 KiB
24Wrong answer146ms600 KiB
25Accepted131ms512 KiB
26Wrong answer194ms1204 KiB
27Wrong answer241ms1904 KiB
28Wrong answer246ms1948 KiB
29Wrong answer241ms1848 KiB
30Wrong answer212ms1848 KiB
subtask50/38
31Accepted1ms320 KiB
32Accepted1ms320 KiB
33Accepted1ms320 KiB
34Accepted1ms508 KiB
35Wrong answer12ms500 KiB
36Wrong answer137ms408 KiB
37Wrong answer246ms1984 KiB
38Wrong answer246ms1980 KiB
39Wrong answer247ms1968 KiB
40Wrong answer250ms1896 KiB
41Wrong answer246ms1848 KiB
42Wrong answer246ms1848 KiB