22652023-01-08 09:43:381478Szemetessorcpp17Wrong answer 17/10079ms7536 KiB
#include <bits/stdc++.h>
#include <random>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> p32;
typedef pair<ll, ll> p64;
typedef pair<double, double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int>> vv32;
typedef vector<vector<ll>> vv64;
typedef vector<vector<p64>> vvp64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 998244353;
double eps = 1e-12;
#define forn(i, e) for (ll i = 0; i < e; i++)
#define forsn(i, s, e) for (ll i = s; i < e; i++)
#define rforn(i, s) for (ll i = s; i >= 0; i--)
#define rforsn(i, s, e) for (ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout << #x << " = " << x << ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF 2e18
#define fast_cin()                    \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())

int main()
{
    fast_cin();
    //ifstream cin("in.txt");

    int n;
    cin >> n;

    int k;
    cin >> k;

    vector<int> capacity(n);
    for (int i = 0; i < n; i++)
    {
        cin >> capacity[i];
    }

    vector<int> full(n);
    int ans = 0;

    for (int i = 0; i < k; i++)
    {
        int ind;
        cin >> ind;

        int val;
        cin >> val;

        if (full[ind] + val <= capacity[ind])
        {
            full[ind] += val;
        }
        else
        {
            ans += capacity[ind] - full[ind];
            full[ind] = val;
        }
    }


    for (int i = 0; i < n; i++)
    {
        if (full[i] != 0)
        {
            ans += capacity[i] - full[i];
        }
    }

    cout << ans;

    return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1824 KiB
2Accepted2ms2064 KiB
subtask217/17
3Accepted2ms2152 KiB
4Accepted2ms2352 KiB
5Accepted2ms2532 KiB
6Accepted2ms2748 KiB
7Accepted2ms2932 KiB
8Accepted2ms3012 KiB
9Accepted2ms3012 KiB
10Accepted2ms3232 KiB
11Accepted2ms3436 KiB
subtask30/25
12Wrong answer41ms3428 KiB
13Wrong answer41ms3556 KiB
14Wrong answer43ms3660 KiB
15Wrong answer46ms3656 KiB
16Wrong answer48ms3704 KiB
17Wrong answer61ms5220 KiB
18Wrong answer78ms6724 KiB
19Wrong answer78ms7040 KiB
20Wrong answer76ms7184 KiB
subtask40/20
21Accepted43ms4280 KiB
22Wrong answer48ms4784 KiB
23Accepted43ms4116 KiB
24Wrong answer48ms4604 KiB
25Accepted45ms4324 KiB
26Wrong answer61ms5608 KiB
27Wrong answer76ms7044 KiB
28Wrong answer78ms7268 KiB
29Wrong answer76ms7340 KiB
30Wrong answer71ms7340 KiB
subtask50/38
31Accepted2ms4492 KiB
32Accepted2ms4444 KiB
33Accepted2ms4544 KiB
34Accepted2ms4440 KiB
35Wrong answer6ms4624 KiB
36Wrong answer45ms4548 KiB
37Wrong answer79ms7436 KiB
38Wrong answer79ms7456 KiB
39Wrong answer79ms7340 KiB
40Wrong answer79ms7384 KiB
41Wrong answer79ms7340 KiB
42Wrong answer79ms7536 KiB