61972023-11-06 18:16:55horvathabelSzemetessorcpp17Wrong answer 25/100256ms12092 KiB
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main()
{
    int n,k;
    cin>>n>>k;
    vector<ll> s(n+1,0);
    vector<ll> l;
    for (int i=0;i<n;i++){
        int x;
        cin>>x;
        l.push_back(x);
    }
    ll ans=0;
    for (int i=0; i<k;i++){
        ll x,y;
        cin>>x>>y;
        if (s[x]+y>l[x]){
            ans+=l[x]-s[x];
            s[x]=y;
        }
        else s[x]+=y;
    }
    for (int i=0; i<n;i++) ans+=l[i]-s[i];
    cout<<ans;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1684 KiB
2Accepted3ms1996 KiB
subtask20/17
3Accepted3ms2048 KiB
4Accepted2ms2056 KiB
5Accepted3ms2184 KiB
6Wrong answer3ms2272 KiB
7Accepted3ms2400 KiB
8Accepted3ms2760 KiB
9Wrong answer2ms2848 KiB
10Accepted2ms2840 KiB
11Wrong answer2ms2968 KiB
subtask325/25
12Accepted119ms3092 KiB
13Accepted120ms3508 KiB
14Accepted133ms3604 KiB
15Accepted138ms3740 KiB
16Accepted150ms4164 KiB
17Accepted201ms7320 KiB
18Accepted250ms10756 KiB
19Accepted248ms11008 KiB
20Accepted254ms10972 KiB
subtask40/20
21Wrong answer125ms4316 KiB
22Wrong answer146ms5828 KiB
23Wrong answer127ms4376 KiB
24Wrong answer146ms4848 KiB
25Wrong answer134ms4368 KiB
26Wrong answer199ms7568 KiB
27Wrong answer243ms11092 KiB
28Wrong answer244ms11140 KiB
29Wrong answer245ms11136 KiB
30Wrong answer217ms11524 KiB
subtask50/38
31Accepted3ms4412 KiB
32Accepted2ms4400 KiB
33Wrong answer3ms4536 KiB
34Wrong answer3ms4400 KiB
35Wrong answer14ms4980 KiB
36Wrong answer138ms4536 KiB
37Wrong answer254ms11760 KiB
38Wrong answer254ms12064 KiB
39Wrong answer254ms12092 KiB
40Wrong answer254ms12028 KiB
41Wrong answer252ms12016 KiB
42Wrong answer256ms12048 KiB