60812023-10-29 16:43:19IgnácSzemetessorcpp11Wrong answer 17/100254ms8316 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
2Accepted3ms2000 KiB
subtask217/17
3Accepted3ms2216 KiB
4Accepted3ms2460 KiB
5Accepted3ms2704 KiB
6Accepted2ms2816 KiB
7Accepted2ms2788 KiB
8Accepted3ms3032 KiB
9Accepted3ms3128 KiB
10Accepted3ms3340 KiB
11Accepted3ms3388 KiB
subtask30/25
12Wrong answer120ms3512 KiB
13Wrong answer120ms3516 KiB
14Wrong answer136ms3640 KiB
15Wrong answer140ms3856 KiB
16Wrong answer152ms3968 KiB
17Wrong answer202ms5380 KiB
18Wrong answer250ms7024 KiB
19Wrong answer252ms7348 KiB
20Wrong answer250ms7300 KiB
subtask40/20
21Wrong answer125ms4464 KiB
22Wrong answer145ms4912 KiB
23Wrong answer127ms4384 KiB
24Wrong answer148ms4720 KiB
25Wrong answer134ms4384 KiB
26Wrong answer197ms5620 KiB
27Wrong answer245ms7020 KiB
28Wrong answer246ms7124 KiB
29Wrong answer246ms7352 KiB
30Wrong answer215ms7364 KiB
subtask50/38
31Accepted3ms4664 KiB
32Wrong answer3ms4732 KiB
33Accepted3ms4860 KiB
34Accepted3ms4892 KiB
35Wrong answer14ms4968 KiB
36Wrong answer141ms5056 KiB
37Wrong answer254ms8004 KiB
38Wrong answer252ms8000 KiB
39Wrong answer254ms7968 KiB
40Wrong answer252ms8040 KiB
41Wrong answer254ms8260 KiB
42Wrong answer254ms8316 KiB