2266 | 2023-01-08 10:42:10 | 1478 | Szemetessor | cpp17 | Elfogadva 100/100 | 82ms | 7892 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);
long long 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;
}
Részfeladat | Összpont | Teszt | Verdikt | Idő | Memória | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Elfogadva | 3ms | 1832 KiB | ||||
2 | Elfogadva | 2ms | 2048 KiB | ||||
subtask2 | 17/17 | ||||||
3 | Elfogadva | 2ms | 2256 KiB | ||||
4 | Elfogadva | 2ms | 2460 KiB | ||||
5 | Elfogadva | 2ms | 2676 KiB | ||||
6 | Elfogadva | 2ms | 2884 KiB | ||||
7 | Elfogadva | 2ms | 3104 KiB | ||||
8 | Elfogadva | 2ms | 3196 KiB | ||||
9 | Elfogadva | 2ms | 3304 KiB | ||||
10 | Elfogadva | 2ms | 3412 KiB | ||||
11 | Elfogadva | 2ms | 3476 KiB | ||||
subtask3 | 25/25 | ||||||
12 | Elfogadva | 41ms | 3480 KiB | ||||
13 | Elfogadva | 41ms | 3684 KiB | ||||
14 | Elfogadva | 45ms | 3888 KiB | ||||
15 | Elfogadva | 46ms | 4084 KiB | ||||
16 | Elfogadva | 48ms | 4348 KiB | ||||
17 | Elfogadva | 64ms | 5744 KiB | ||||
18 | Elfogadva | 78ms | 7760 KiB | ||||
19 | Elfogadva | 78ms | 7712 KiB | ||||
20 | Elfogadva | 78ms | 7752 KiB | ||||
subtask4 | 20/20 | ||||||
21 | Elfogadva | 46ms | 4896 KiB | ||||
22 | Elfogadva | 48ms | 5480 KiB | ||||
23 | Elfogadva | 46ms | 4720 KiB | ||||
24 | Elfogadva | 50ms | 4948 KiB | ||||
25 | Elfogadva | 48ms | 4720 KiB | ||||
26 | Elfogadva | 63ms | 5984 KiB | ||||
27 | Elfogadva | 78ms | 7416 KiB | ||||
28 | Elfogadva | 78ms | 7540 KiB | ||||
29 | Elfogadva | 81ms | 7540 KiB | ||||
30 | Elfogadva | 74ms | 7560 KiB | ||||
subtask5 | 38/38 | ||||||
31 | Elfogadva | 2ms | 4792 KiB | ||||
32 | Elfogadva | 2ms | 4644 KiB | ||||
33 | Elfogadva | 2ms | 4640 KiB | ||||
34 | Elfogadva | 2ms | 4648 KiB | ||||
35 | Elfogadva | 6ms | 4980 KiB | ||||
36 | Elfogadva | 46ms | 4964 KiB | ||||
37 | Elfogadva | 81ms | 7748 KiB | ||||
38 | Elfogadva | 82ms | 7748 KiB | ||||
39 | Elfogadva | 82ms | 7744 KiB | ||||
40 | Elfogadva | 81ms | 7744 KiB | ||||
41 | Elfogadva | 79ms | 7744 KiB | ||||
42 | Elfogadva | 79ms | 7892 KiB |