60802023-10-29 16:39:55IgnácSzemetessorcpp11Wrong answer 17/100256ms8144 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {
	int N, K;
	cin >> N >> K;
	vector<int> C(N);
	for(int i = 0; i < N; i++){
		cin >> C[i];
	}

	vector<int> teli(N);
	int ar = 0;
	for(int i = 0; i < K; i++){
		int T, Q;
		cin >> T >> Q;
		if(teli[T] + Q > C[T]){
			ar += C[T] - teli[T];
			teli[T] = 0;
		}
		teli[T] += Q;
	}

	for(int i = 0; i < N; i++){
		if(teli[i] > 0){
			ar += C[i] - teli[i];
		}
	}

	cout << ar << "\n";
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1808 KiB
2Accepted3ms1984 KiB
subtask217/17
3Accepted3ms2240 KiB
4Accepted3ms2444 KiB
5Accepted3ms2652 KiB
6Accepted3ms2868 KiB
7Accepted3ms3112 KiB
8Accepted3ms3292 KiB
9Accepted3ms3504 KiB
10Accepted3ms3744 KiB
11Accepted3ms3964 KiB
subtask30/25
12Wrong answer120ms4076 KiB
13Wrong answer122ms4288 KiB
14Wrong answer135ms4464 KiB
15Wrong answer140ms4496 KiB
16Wrong answer152ms4388 KiB
17Wrong answer202ms5660 KiB
18Wrong answer250ms7308 KiB
19Wrong answer250ms7372 KiB
20Wrong answer250ms7636 KiB
subtask40/20
21Accepted126ms4924 KiB
22Wrong answer150ms5508 KiB
23Accepted127ms4972 KiB
24Wrong answer148ms5264 KiB
25Accepted135ms5064 KiB
26Wrong answer197ms6224 KiB
27Wrong answer246ms7740 KiB
28Wrong answer248ms7868 KiB
29Wrong answer254ms7964 KiB
30Wrong answer215ms7976 KiB
subtask50/38
31Accepted2ms5140 KiB
32Accepted3ms5064 KiB
33Accepted3ms5072 KiB
34Accepted3ms5064 KiB
35Wrong answer14ms5260 KiB
36Wrong answer141ms5084 KiB
37Wrong answer256ms8144 KiB
38Wrong answer252ms8124 KiB
39Wrong answer254ms8120 KiB
40Wrong answer252ms8124 KiB
41Wrong answer252ms8124 KiB
42Wrong answer254ms8120 KiB