# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
123287 | 2019-07-01T05:47:32 Z | 김세빈(#3018) | Two Dishes (JOI19_dishes) | C++14 | 2778 ms | 175700 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; struct fenwick{ ll T[1010101]; ll m; void init(int _m) { m = _m; } void addval(ll p, ll v) { if(!p) T[0] += v; else{ for(; p<=m; p+=p&-p){ T[p] += v; } } } ll getval(ll p) { ll ret = T[0]; for(; p; p-=p&-p){ ret += T[p]; } return ret; } }; ll A[1010101], S[1010101], P[1010101]; ll B[1010101], T[1010101], Q[1010101]; vector <ll> V[1010101]; set <ll> X; fenwick F; ll n, m; int main() { ll i, k, t; scanf("%lld%lld", &n, &m); for(i=1; i<=n; i++){ scanf("%lld%lld%lld", A + i, S + i, P + i); A[i] += A[i - 1]; } for(i=1; i<=m; i++){ scanf("%lld%lld%lld", B + i, T + i, Q + i); B[i] += B[i - 1]; } for(i=1; i<=n; i++){ S[i] = upper_bound(B, B + m + 1, S[i] - A[i]) - B; } for(i=1; i<=m; i++){ T[i] = upper_bound(A, A + n + 1, T[i] - B[i]) - A; V[T[i]].push_back(i); } F.init(m); for(i=1; i<=m; i++){ if(T[i] == 0) F.addval(i, 0); else F.addval(i, Q[i]); } for(i=1; i<=n; i++){ for(ll &t: V[i]){ X.insert(t); } if(S[i] == 0) continue; k = P[i]; F.addval(0, k); for(; ; ){ auto it = X.lower_bound(S[i]); if(it == X.end()) break; t = F.getval(*it) - F.getval(*it - 1); if(t <= k){ F.addval(*it, -t); k -= t; X.erase(it); } else{ F.addval(*it, -k); break; } } } printf("%lld\n", F.getval(m)); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 317 ms | 49776 KB | Output is correct |
2 | Correct | 285 ms | 41588 KB | Output is correct |
3 | Correct | 252 ms | 39416 KB | Output is correct |
4 | Correct | 316 ms | 47008 KB | Output is correct |
5 | Correct | 23 ms | 24056 KB | Output is correct |
6 | Correct | 293 ms | 40920 KB | Output is correct |
7 | Correct | 133 ms | 35556 KB | Output is correct |
8 | Correct | 127 ms | 32376 KB | Output is correct |
9 | Correct | 251 ms | 39524 KB | Output is correct |
10 | Correct | 253 ms | 44920 KB | Output is correct |
11 | Correct | 182 ms | 40548 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 23 ms | 24056 KB | Output is correct |
2 | Correct | 23 ms | 24056 KB | Output is correct |
3 | Correct | 22 ms | 24056 KB | Output is correct |
4 | Correct | 23 ms | 24060 KB | Output is correct |
5 | Correct | 23 ms | 24056 KB | Output is correct |
6 | Correct | 22 ms | 24056 KB | Output is correct |
7 | Correct | 28 ms | 24056 KB | Output is correct |
8 | Correct | 24 ms | 24184 KB | Output is correct |
9 | Correct | 23 ms | 24184 KB | Output is correct |
10 | Correct | 23 ms | 24028 KB | Output is correct |
11 | Correct | 23 ms | 24056 KB | Output is correct |
12 | Correct | 28 ms | 24056 KB | Output is correct |
13 | Correct | 23 ms | 24056 KB | Output is correct |
14 | Correct | 23 ms | 24060 KB | Output is correct |
15 | Correct | 22 ms | 24060 KB | Output is correct |
16 | Correct | 23 ms | 24056 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 23 ms | 24056 KB | Output is correct |
2 | Correct | 23 ms | 24056 KB | Output is correct |
3 | Correct | 22 ms | 24056 KB | Output is correct |
4 | Correct | 23 ms | 24060 KB | Output is correct |
5 | Correct | 23 ms | 24056 KB | Output is correct |
6 | Correct | 22 ms | 24056 KB | Output is correct |
7 | Correct | 28 ms | 24056 KB | Output is correct |
8 | Correct | 24 ms | 24184 KB | Output is correct |
9 | Correct | 23 ms | 24184 KB | Output is correct |
10 | Correct | 23 ms | 24028 KB | Output is correct |
11 | Correct | 23 ms | 24056 KB | Output is correct |
12 | Correct | 28 ms | 24056 KB | Output is correct |
13 | Correct | 23 ms | 24056 KB | Output is correct |
14 | Correct | 23 ms | 24060 KB | Output is correct |
15 | Correct | 22 ms | 24060 KB | Output is correct |
16 | Correct | 23 ms | 24056 KB | Output is correct |
17 | Correct | 25 ms | 24184 KB | Output is correct |
18 | Correct | 25 ms | 24312 KB | Output is correct |
19 | Correct | 26 ms | 24312 KB | Output is correct |
20 | Correct | 25 ms | 24184 KB | Output is correct |
21 | Correct | 26 ms | 24312 KB | Output is correct |
22 | Correct | 30 ms | 24184 KB | Output is correct |
23 | Correct | 25 ms | 24184 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 23 ms | 24056 KB | Output is correct |
2 | Correct | 23 ms | 24056 KB | Output is correct |
3 | Correct | 22 ms | 24056 KB | Output is correct |
4 | Correct | 23 ms | 24060 KB | Output is correct |
5 | Correct | 23 ms | 24056 KB | Output is correct |
6 | Correct | 22 ms | 24056 KB | Output is correct |
7 | Correct | 28 ms | 24056 KB | Output is correct |
8 | Correct | 24 ms | 24184 KB | Output is correct |
9 | Correct | 23 ms | 24184 KB | Output is correct |
10 | Correct | 23 ms | 24028 KB | Output is correct |
11 | Correct | 23 ms | 24056 KB | Output is correct |
12 | Correct | 28 ms | 24056 KB | Output is correct |
13 | Correct | 23 ms | 24056 KB | Output is correct |
14 | Correct | 23 ms | 24060 KB | Output is correct |
15 | Correct | 22 ms | 24060 KB | Output is correct |
16 | Correct | 23 ms | 24056 KB | Output is correct |
17 | Correct | 25 ms | 24184 KB | Output is correct |
18 | Correct | 25 ms | 24312 KB | Output is correct |
19 | Correct | 26 ms | 24312 KB | Output is correct |
20 | Correct | 25 ms | 24184 KB | Output is correct |
21 | Correct | 26 ms | 24312 KB | Output is correct |
22 | Correct | 30 ms | 24184 KB | Output is correct |
23 | Correct | 25 ms | 24184 KB | Output is correct |
24 | Correct | 223 ms | 39636 KB | Output is correct |
25 | Correct | 306 ms | 49024 KB | Output is correct |
26 | Correct | 234 ms | 39828 KB | Output is correct |
27 | Correct | 321 ms | 53624 KB | Output is correct |
28 | Correct | 281 ms | 40552 KB | Output is correct |
29 | Correct | 207 ms | 39396 KB | Output is correct |
30 | Correct | 419 ms | 40444 KB | Output is correct |
31 | Correct | 147 ms | 36728 KB | Output is correct |
32 | Correct | 113 ms | 28792 KB | Output is correct |
33 | Correct | 322 ms | 38252 KB | Output is correct |
34 | Correct | 386 ms | 41944 KB | Output is correct |
35 | Correct | 354 ms | 39288 KB | Output is correct |
36 | Correct | 356 ms | 39324 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 23 ms | 24056 KB | Output is correct |
2 | Correct | 23 ms | 24056 KB | Output is correct |
3 | Correct | 22 ms | 24056 KB | Output is correct |
4 | Correct | 23 ms | 24060 KB | Output is correct |
5 | Correct | 23 ms | 24056 KB | Output is correct |
6 | Correct | 22 ms | 24056 KB | Output is correct |
7 | Correct | 28 ms | 24056 KB | Output is correct |
8 | Correct | 24 ms | 24184 KB | Output is correct |
9 | Correct | 23 ms | 24184 KB | Output is correct |
10 | Correct | 23 ms | 24028 KB | Output is correct |
11 | Correct | 23 ms | 24056 KB | Output is correct |
12 | Correct | 28 ms | 24056 KB | Output is correct |
13 | Correct | 23 ms | 24056 KB | Output is correct |
14 | Correct | 23 ms | 24060 KB | Output is correct |
15 | Correct | 22 ms | 24060 KB | Output is correct |
16 | Correct | 23 ms | 24056 KB | Output is correct |
17 | Correct | 25 ms | 24184 KB | Output is correct |
18 | Correct | 25 ms | 24312 KB | Output is correct |
19 | Correct | 26 ms | 24312 KB | Output is correct |
20 | Correct | 25 ms | 24184 KB | Output is correct |
21 | Correct | 26 ms | 24312 KB | Output is correct |
22 | Correct | 30 ms | 24184 KB | Output is correct |
23 | Correct | 25 ms | 24184 KB | Output is correct |
24 | Correct | 223 ms | 39636 KB | Output is correct |
25 | Correct | 306 ms | 49024 KB | Output is correct |
26 | Correct | 234 ms | 39828 KB | Output is correct |
27 | Correct | 321 ms | 53624 KB | Output is correct |
28 | Correct | 281 ms | 40552 KB | Output is correct |
29 | Correct | 207 ms | 39396 KB | Output is correct |
30 | Correct | 419 ms | 40444 KB | Output is correct |
31 | Correct | 147 ms | 36728 KB | Output is correct |
32 | Correct | 113 ms | 28792 KB | Output is correct |
33 | Correct | 322 ms | 38252 KB | Output is correct |
34 | Correct | 386 ms | 41944 KB | Output is correct |
35 | Correct | 354 ms | 39288 KB | Output is correct |
36 | Correct | 356 ms | 39324 KB | Output is correct |
37 | Correct | 280 ms | 36792 KB | Output is correct |
38 | Correct | 358 ms | 50716 KB | Output is correct |
39 | Correct | 385 ms | 50680 KB | Output is correct |
40 | Correct | 271 ms | 41336 KB | Output is correct |
41 | Correct | 25 ms | 24056 KB | Output is correct |
42 | Correct | 474 ms | 39476 KB | Output is correct |
43 | Correct | 364 ms | 38248 KB | Output is correct |
44 | Correct | 418 ms | 41904 KB | Output is correct |
45 | Correct | 433 ms | 39400 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 23 ms | 24056 KB | Output is correct |
2 | Correct | 23 ms | 24056 KB | Output is correct |
3 | Correct | 22 ms | 24056 KB | Output is correct |
4 | Correct | 23 ms | 24060 KB | Output is correct |
5 | Correct | 23 ms | 24056 KB | Output is correct |
6 | Correct | 22 ms | 24056 KB | Output is correct |
7 | Correct | 28 ms | 24056 KB | Output is correct |
8 | Correct | 24 ms | 24184 KB | Output is correct |
9 | Correct | 23 ms | 24184 KB | Output is correct |
10 | Correct | 23 ms | 24028 KB | Output is correct |
11 | Correct | 23 ms | 24056 KB | Output is correct |
12 | Correct | 28 ms | 24056 KB | Output is correct |
13 | Correct | 23 ms | 24056 KB | Output is correct |
14 | Correct | 23 ms | 24060 KB | Output is correct |
15 | Correct | 22 ms | 24060 KB | Output is correct |
16 | Correct | 23 ms | 24056 KB | Output is correct |
17 | Correct | 25 ms | 24184 KB | Output is correct |
18 | Correct | 25 ms | 24312 KB | Output is correct |
19 | Correct | 26 ms | 24312 KB | Output is correct |
20 | Correct | 25 ms | 24184 KB | Output is correct |
21 | Correct | 26 ms | 24312 KB | Output is correct |
22 | Correct | 30 ms | 24184 KB | Output is correct |
23 | Correct | 25 ms | 24184 KB | Output is correct |
24 | Correct | 223 ms | 39636 KB | Output is correct |
25 | Correct | 306 ms | 49024 KB | Output is correct |
26 | Correct | 234 ms | 39828 KB | Output is correct |
27 | Correct | 321 ms | 53624 KB | Output is correct |
28 | Correct | 281 ms | 40552 KB | Output is correct |
29 | Correct | 207 ms | 39396 KB | Output is correct |
30 | Correct | 419 ms | 40444 KB | Output is correct |
31 | Correct | 147 ms | 36728 KB | Output is correct |
32 | Correct | 113 ms | 28792 KB | Output is correct |
33 | Correct | 322 ms | 38252 KB | Output is correct |
34 | Correct | 386 ms | 41944 KB | Output is correct |
35 | Correct | 354 ms | 39288 KB | Output is correct |
36 | Correct | 356 ms | 39324 KB | Output is correct |
37 | Correct | 280 ms | 36792 KB | Output is correct |
38 | Correct | 358 ms | 50716 KB | Output is correct |
39 | Correct | 385 ms | 50680 KB | Output is correct |
40 | Correct | 271 ms | 41336 KB | Output is correct |
41 | Correct | 25 ms | 24056 KB | Output is correct |
42 | Correct | 474 ms | 39476 KB | Output is correct |
43 | Correct | 364 ms | 38248 KB | Output is correct |
44 | Correct | 418 ms | 41904 KB | Output is correct |
45 | Correct | 433 ms | 39400 KB | Output is correct |
46 | Correct | 1312 ms | 87024 KB | Output is correct |
47 | Correct | 1825 ms | 157264 KB | Output is correct |
48 | Correct | 2202 ms | 175700 KB | Output is correct |
49 | Correct | 1297 ms | 128984 KB | Output is correct |
50 | Correct | 2778 ms | 123596 KB | Output is correct |
51 | Correct | 1921 ms | 115412 KB | Output is correct |
52 | Correct | 2420 ms | 131252 KB | Output is correct |
53 | Correct | 2288 ms | 112400 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 317 ms | 49776 KB | Output is correct |
2 | Correct | 285 ms | 41588 KB | Output is correct |
3 | Correct | 252 ms | 39416 KB | Output is correct |
4 | Correct | 316 ms | 47008 KB | Output is correct |
5 | Correct | 23 ms | 24056 KB | Output is correct |
6 | Correct | 293 ms | 40920 KB | Output is correct |
7 | Correct | 133 ms | 35556 KB | Output is correct |
8 | Correct | 127 ms | 32376 KB | Output is correct |
9 | Correct | 251 ms | 39524 KB | Output is correct |
10 | Correct | 253 ms | 44920 KB | Output is correct |
11 | Correct | 182 ms | 40548 KB | Output is correct |
12 | Correct | 23 ms | 24056 KB | Output is correct |
13 | Correct | 23 ms | 24056 KB | Output is correct |
14 | Correct | 22 ms | 24056 KB | Output is correct |
15 | Correct | 23 ms | 24060 KB | Output is correct |
16 | Correct | 23 ms | 24056 KB | Output is correct |
17 | Correct | 22 ms | 24056 KB | Output is correct |
18 | Correct | 28 ms | 24056 KB | Output is correct |
19 | Correct | 24 ms | 24184 KB | Output is correct |
20 | Correct | 23 ms | 24184 KB | Output is correct |
21 | Correct | 23 ms | 24028 KB | Output is correct |
22 | Correct | 23 ms | 24056 KB | Output is correct |
23 | Correct | 28 ms | 24056 KB | Output is correct |
24 | Correct | 23 ms | 24056 KB | Output is correct |
25 | Correct | 23 ms | 24060 KB | Output is correct |
26 | Correct | 22 ms | 24060 KB | Output is correct |
27 | Correct | 23 ms | 24056 KB | Output is correct |
28 | Correct | 25 ms | 24184 KB | Output is correct |
29 | Correct | 25 ms | 24312 KB | Output is correct |
30 | Correct | 26 ms | 24312 KB | Output is correct |
31 | Correct | 25 ms | 24184 KB | Output is correct |
32 | Correct | 26 ms | 24312 KB | Output is correct |
33 | Correct | 30 ms | 24184 KB | Output is correct |
34 | Correct | 25 ms | 24184 KB | Output is correct |
35 | Correct | 223 ms | 39636 KB | Output is correct |
36 | Correct | 306 ms | 49024 KB | Output is correct |
37 | Correct | 234 ms | 39828 KB | Output is correct |
38 | Correct | 321 ms | 53624 KB | Output is correct |
39 | Correct | 281 ms | 40552 KB | Output is correct |
40 | Correct | 207 ms | 39396 KB | Output is correct |
41 | Correct | 419 ms | 40444 KB | Output is correct |
42 | Correct | 147 ms | 36728 KB | Output is correct |
43 | Correct | 113 ms | 28792 KB | Output is correct |
44 | Correct | 322 ms | 38252 KB | Output is correct |
45 | Correct | 386 ms | 41944 KB | Output is correct |
46 | Correct | 354 ms | 39288 KB | Output is correct |
47 | Correct | 356 ms | 39324 KB | Output is correct |
48 | Correct | 280 ms | 36792 KB | Output is correct |
49 | Correct | 358 ms | 50716 KB | Output is correct |
50 | Correct | 385 ms | 50680 KB | Output is correct |
51 | Correct | 271 ms | 41336 KB | Output is correct |
52 | Correct | 25 ms | 24056 KB | Output is correct |
53 | Correct | 474 ms | 39476 KB | Output is correct |
54 | Correct | 364 ms | 38248 KB | Output is correct |
55 | Correct | 418 ms | 41904 KB | Output is correct |
56 | Correct | 433 ms | 39400 KB | Output is correct |
57 | Incorrect | 272 ms | 38756 KB | Output isn't correct |
58 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 317 ms | 49776 KB | Output is correct |
2 | Correct | 285 ms | 41588 KB | Output is correct |
3 | Correct | 252 ms | 39416 KB | Output is correct |
4 | Correct | 316 ms | 47008 KB | Output is correct |
5 | Correct | 23 ms | 24056 KB | Output is correct |
6 | Correct | 293 ms | 40920 KB | Output is correct |
7 | Correct | 133 ms | 35556 KB | Output is correct |
8 | Correct | 127 ms | 32376 KB | Output is correct |
9 | Correct | 251 ms | 39524 KB | Output is correct |
10 | Correct | 253 ms | 44920 KB | Output is correct |
11 | Correct | 182 ms | 40548 KB | Output is correct |
12 | Correct | 23 ms | 24056 KB | Output is correct |
13 | Correct | 23 ms | 24056 KB | Output is correct |
14 | Correct | 22 ms | 24056 KB | Output is correct |
15 | Correct | 23 ms | 24060 KB | Output is correct |
16 | Correct | 23 ms | 24056 KB | Output is correct |
17 | Correct | 22 ms | 24056 KB | Output is correct |
18 | Correct | 28 ms | 24056 KB | Output is correct |
19 | Correct | 24 ms | 24184 KB | Output is correct |
20 | Correct | 23 ms | 24184 KB | Output is correct |
21 | Correct | 23 ms | 24028 KB | Output is correct |
22 | Correct | 23 ms | 24056 KB | Output is correct |
23 | Correct | 28 ms | 24056 KB | Output is correct |
24 | Correct | 23 ms | 24056 KB | Output is correct |
25 | Correct | 23 ms | 24060 KB | Output is correct |
26 | Correct | 22 ms | 24060 KB | Output is correct |
27 | Correct | 23 ms | 24056 KB | Output is correct |
28 | Correct | 25 ms | 24184 KB | Output is correct |
29 | Correct | 25 ms | 24312 KB | Output is correct |
30 | Correct | 26 ms | 24312 KB | Output is correct |
31 | Correct | 25 ms | 24184 KB | Output is correct |
32 | Correct | 26 ms | 24312 KB | Output is correct |
33 | Correct | 30 ms | 24184 KB | Output is correct |
34 | Correct | 25 ms | 24184 KB | Output is correct |
35 | Correct | 223 ms | 39636 KB | Output is correct |
36 | Correct | 306 ms | 49024 KB | Output is correct |
37 | Correct | 234 ms | 39828 KB | Output is correct |
38 | Correct | 321 ms | 53624 KB | Output is correct |
39 | Correct | 281 ms | 40552 KB | Output is correct |
40 | Correct | 207 ms | 39396 KB | Output is correct |
41 | Correct | 419 ms | 40444 KB | Output is correct |
42 | Correct | 147 ms | 36728 KB | Output is correct |
43 | Correct | 113 ms | 28792 KB | Output is correct |
44 | Correct | 322 ms | 38252 KB | Output is correct |
45 | Correct | 386 ms | 41944 KB | Output is correct |
46 | Correct | 354 ms | 39288 KB | Output is correct |
47 | Correct | 356 ms | 39324 KB | Output is correct |
48 | Correct | 280 ms | 36792 KB | Output is correct |
49 | Correct | 358 ms | 50716 KB | Output is correct |
50 | Correct | 385 ms | 50680 KB | Output is correct |
51 | Correct | 271 ms | 41336 KB | Output is correct |
52 | Correct | 25 ms | 24056 KB | Output is correct |
53 | Correct | 474 ms | 39476 KB | Output is correct |
54 | Correct | 364 ms | 38248 KB | Output is correct |
55 | Correct | 418 ms | 41904 KB | Output is correct |
56 | Correct | 433 ms | 39400 KB | Output is correct |
57 | Correct | 1312 ms | 87024 KB | Output is correct |
58 | Correct | 1825 ms | 157264 KB | Output is correct |
59 | Correct | 2202 ms | 175700 KB | Output is correct |
60 | Correct | 1297 ms | 128984 KB | Output is correct |
61 | Correct | 2778 ms | 123596 KB | Output is correct |
62 | Correct | 1921 ms | 115412 KB | Output is correct |
63 | Correct | 2420 ms | 131252 KB | Output is correct |
64 | Correct | 2288 ms | 112400 KB | Output is correct |
65 | Incorrect | 272 ms | 38756 KB | Output isn't correct |
66 | Halted | 0 ms | 0 KB | - |