60762023-10-29 16:29:12IgnácSzemetessorcpp11Wrong answer 17/100266ms108108 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;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1936 KiB
2Accepted3ms1908 KiB
subtask217/17
3Accepted3ms2112 KiB
4Accepted3ms2332 KiB
5Accepted3ms2544 KiB
6Accepted3ms2792 KiB
7Accepted3ms2876 KiB
8Accepted3ms3156 KiB
9Accepted3ms3132 KiB
10Accepted3ms3176 KiB
11Accepted3ms3156 KiB
subtask30/25
12Wrong answer123ms5216 KiB
13Wrong answer125ms7288 KiB
14Wrong answer140ms9792 KiB
15Wrong answer143ms12480 KiB
16Wrong answer157ms15704 KiB
17Wrong answer208ms21244 KiB
18Wrong answer259ms28052 KiB
19Wrong answer261ms33132 KiB
20Wrong answer256ms38276 KiB
subtask40/20
21Accepted129ms37672 KiB
22Wrong answer149ms41024 KiB
23Accepted129ms42592 KiB
24Wrong answer156ms45952 KiB
25Accepted137ms48392 KiB
26Wrong answer202ms53492 KiB
27Wrong answer252ms59892 KiB
28Wrong answer252ms65164 KiB
29Wrong answer254ms70196 KiB
30Wrong answer219ms74160 KiB
subtask50/38
31Accepted3ms71432 KiB
32Accepted2ms71552 KiB
33Accepted3ms71556 KiB
34Accepted3ms71552 KiB
35Wrong answer14ms71892 KiB
36Wrong answer144ms74608 KiB
37Wrong answer259ms82688 KiB
38Wrong answer261ms87784 KiB
39Wrong answer263ms92980 KiB
40Wrong answer261ms97936 KiB
41Wrong answer266ms103028 KiB
42Wrong answer263ms108108 KiB