2265 | 2023-01-08 09:43:38 | 1478 | Szemetessor | cpp17 | Wrong answer 17/100 | 79ms | 7536 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;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1824 KiB | ||||
2 | Accepted | 2ms | 2064 KiB | ||||
subtask2 | 17/17 | ||||||
3 | Accepted | 2ms | 2152 KiB | ||||
4 | Accepted | 2ms | 2352 KiB | ||||
5 | Accepted | 2ms | 2532 KiB | ||||
6 | Accepted | 2ms | 2748 KiB | ||||
7 | Accepted | 2ms | 2932 KiB | ||||
8 | Accepted | 2ms | 3012 KiB | ||||
9 | Accepted | 2ms | 3012 KiB | ||||
10 | Accepted | 2ms | 3232 KiB | ||||
11 | Accepted | 2ms | 3436 KiB | ||||
subtask3 | 0/25 | ||||||
12 | Wrong answer | 41ms | 3428 KiB | ||||
13 | Wrong answer | 41ms | 3556 KiB | ||||
14 | Wrong answer | 43ms | 3660 KiB | ||||
15 | Wrong answer | 46ms | 3656 KiB | ||||
16 | Wrong answer | 48ms | 3704 KiB | ||||
17 | Wrong answer | 61ms | 5220 KiB | ||||
18 | Wrong answer | 78ms | 6724 KiB | ||||
19 | Wrong answer | 78ms | 7040 KiB | ||||
20 | Wrong answer | 76ms | 7184 KiB | ||||
subtask4 | 0/20 | ||||||
21 | Accepted | 43ms | 4280 KiB | ||||
22 | Wrong answer | 48ms | 4784 KiB | ||||
23 | Accepted | 43ms | 4116 KiB | ||||
24 | Wrong answer | 48ms | 4604 KiB | ||||
25 | Accepted | 45ms | 4324 KiB | ||||
26 | Wrong answer | 61ms | 5608 KiB | ||||
27 | Wrong answer | 76ms | 7044 KiB | ||||
28 | Wrong answer | 78ms | 7268 KiB | ||||
29 | Wrong answer | 76ms | 7340 KiB | ||||
30 | Wrong answer | 71ms | 7340 KiB | ||||
subtask5 | 0/38 | ||||||
31 | Accepted | 2ms | 4492 KiB | ||||
32 | Accepted | 2ms | 4444 KiB | ||||
33 | Accepted | 2ms | 4544 KiB | ||||
34 | Accepted | 2ms | 4440 KiB | ||||
35 | Wrong answer | 6ms | 4624 KiB | ||||
36 | Wrong answer | 45ms | 4548 KiB | ||||
37 | Wrong answer | 79ms | 7436 KiB | ||||
38 | Wrong answer | 79ms | 7456 KiB | ||||
39 | Wrong answer | 79ms | 7340 KiB | ||||
40 | Wrong answer | 79ms | 7384 KiB | ||||
41 | Wrong answer | 79ms | 7340 KiB | ||||
42 | Wrong answer | 79ms | 7536 KiB |