# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
389662 | 2021-04-14T11:04:07 Z | denkendoemeer | Two Dishes (JOI19_dishes) | C++14 | 3271 ms | 250168 KB |
#include<bits/stdc++.h> #define ll long long const int inf=1e9; using namespace std; ll n,m,ans,a[1000005],b[1000005],s[1000005],t[1000005],p[1000005],q[1000005],suma[1000005],sumb[1000005],d[1000005],lim[1000005]; vector<int>v[1000005],aux; set<int>st; void update(int poz) { ll num=0; while(poz<=m){ int nex=*st.upper_bound(poz); if (d[poz]-num>lim[poz]){ d[poz]-=num; break; } num+=lim[poz]-d[poz]; d[poz]=lim[poz]; st.erase(poz); poz=nex; } } int main() { //freopen(".in","r",stdin); //freopen(".out","w",stdout); scanf("%lld%lld",&n,&m); int i; for(i=1;i<=n;i++){ scanf("%lld%lld%lld",&a[i],&s[i],&p[i]); suma[i]=suma[i-1]+a[i]; } for(i=1;i<=m;i++){ scanf("%lld%lld%lld",&b[i],&t[i],&q[i]); sumb[i]=sumb[i-1]+b[i]; if (sumb[i]>t[i]) continue; d[i]=lim[i]=q[i]; int auxi=upper_bound(suma,suma+n+1,t[i]-sumb[i])-suma; v[auxi].push_back(i); } st.insert(m+1); for(i=1;i<=n;i++){ aux.clear(); if (suma[i]<=s[i]){ int auxi=upper_bound(sumb,sumb+m+1,s[i]-suma[i])-sumb-1; d[0]+=p[i]; d[auxi+1]-=p[i]; st.insert(auxi+1); aux.push_back(auxi+1); } for(auto it:v[i]){ lim[it]=0; st.insert(it); aux.push_back(it); } for(auto it:aux) update(it); } for(i=0;i<=m;i++) ans+=d[i]; printf("%lld\n",ans); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 293 ms | 64824 KB | Output is correct |
2 | Correct | 251 ms | 56800 KB | Output is correct |
3 | Correct | 223 ms | 53880 KB | Output is correct |
4 | Correct | 280 ms | 61252 KB | Output is correct |
5 | Correct | 16 ms | 23756 KB | Output is correct |
6 | Correct | 256 ms | 55452 KB | Output is correct |
7 | Correct | 121 ms | 40632 KB | Output is correct |
8 | Correct | 124 ms | 37084 KB | Output is correct |
9 | Correct | 210 ms | 54804 KB | Output is correct |
10 | Correct | 245 ms | 53184 KB | Output is correct |
11 | Correct | 167 ms | 48116 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 17 ms | 23756 KB | Output is correct |
2 | Correct | 15 ms | 23792 KB | Output is correct |
3 | Correct | 15 ms | 23836 KB | Output is correct |
4 | Correct | 16 ms | 23788 KB | Output is correct |
5 | Correct | 17 ms | 23912 KB | Output is correct |
6 | Correct | 15 ms | 23772 KB | Output is correct |
7 | Correct | 15 ms | 23784 KB | Output is correct |
8 | Correct | 15 ms | 23756 KB | Output is correct |
9 | Correct | 15 ms | 23828 KB | Output is correct |
10 | Correct | 15 ms | 23784 KB | Output is correct |
11 | Correct | 15 ms | 23756 KB | Output is correct |
12 | Correct | 15 ms | 23756 KB | Output is correct |
13 | Correct | 15 ms | 23796 KB | Output is correct |
14 | Correct | 17 ms | 23740 KB | Output is correct |
15 | Correct | 15 ms | 23756 KB | Output is correct |
16 | Correct | 15 ms | 23756 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 17 ms | 23756 KB | Output is correct |
2 | Correct | 15 ms | 23792 KB | Output is correct |
3 | Correct | 15 ms | 23836 KB | Output is correct |
4 | Correct | 16 ms | 23788 KB | Output is correct |
5 | Correct | 17 ms | 23912 KB | Output is correct |
6 | Correct | 15 ms | 23772 KB | Output is correct |
7 | Correct | 15 ms | 23784 KB | Output is correct |
8 | Correct | 15 ms | 23756 KB | Output is correct |
9 | Correct | 15 ms | 23828 KB | Output is correct |
10 | Correct | 15 ms | 23784 KB | Output is correct |
11 | Correct | 15 ms | 23756 KB | Output is correct |
12 | Correct | 15 ms | 23756 KB | Output is correct |
13 | Correct | 15 ms | 23796 KB | Output is correct |
14 | Correct | 17 ms | 23740 KB | Output is correct |
15 | Correct | 15 ms | 23756 KB | Output is correct |
16 | Correct | 15 ms | 23756 KB | Output is correct |
17 | Correct | 17 ms | 24064 KB | Output is correct |
18 | Correct | 17 ms | 24140 KB | Output is correct |
19 | Correct | 18 ms | 24152 KB | Output is correct |
20 | Correct | 18 ms | 24060 KB | Output is correct |
21 | Correct | 18 ms | 24140 KB | Output is correct |
22 | Correct | 18 ms | 24088 KB | Output is correct |
23 | Correct | 18 ms | 24036 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 17 ms | 23756 KB | Output is correct |
2 | Correct | 15 ms | 23792 KB | Output is correct |
3 | Correct | 15 ms | 23836 KB | Output is correct |
4 | Correct | 16 ms | 23788 KB | Output is correct |
5 | Correct | 17 ms | 23912 KB | Output is correct |
6 | Correct | 15 ms | 23772 KB | Output is correct |
7 | Correct | 15 ms | 23784 KB | Output is correct |
8 | Correct | 15 ms | 23756 KB | Output is correct |
9 | Correct | 15 ms | 23828 KB | Output is correct |
10 | Correct | 15 ms | 23784 KB | Output is correct |
11 | Correct | 15 ms | 23756 KB | Output is correct |
12 | Correct | 15 ms | 23756 KB | Output is correct |
13 | Correct | 15 ms | 23796 KB | Output is correct |
14 | Correct | 17 ms | 23740 KB | Output is correct |
15 | Correct | 15 ms | 23756 KB | Output is correct |
16 | Correct | 15 ms | 23756 KB | Output is correct |
17 | Correct | 17 ms | 24064 KB | Output is correct |
18 | Correct | 17 ms | 24140 KB | Output is correct |
19 | Correct | 18 ms | 24152 KB | Output is correct |
20 | Correct | 18 ms | 24060 KB | Output is correct |
21 | Correct | 18 ms | 24140 KB | Output is correct |
22 | Correct | 18 ms | 24088 KB | Output is correct |
23 | Correct | 18 ms | 24036 KB | Output is correct |
24 | Correct | 193 ms | 50468 KB | Output is correct |
25 | Correct | 275 ms | 60984 KB | Output is correct |
26 | Correct | 207 ms | 50648 KB | Output is correct |
27 | Correct | 284 ms | 65832 KB | Output is correct |
28 | Correct | 274 ms | 52156 KB | Output is correct |
29 | Correct | 193 ms | 51652 KB | Output is correct |
30 | Correct | 467 ms | 54256 KB | Output is correct |
31 | Correct | 125 ms | 44288 KB | Output is correct |
32 | Correct | 101 ms | 35216 KB | Output is correct |
33 | Correct | 342 ms | 52376 KB | Output is correct |
34 | Correct | 390 ms | 56220 KB | Output is correct |
35 | Correct | 411 ms | 47684 KB | Output is correct |
36 | Correct | 474 ms | 47776 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 17 ms | 23756 KB | Output is correct |
2 | Correct | 15 ms | 23792 KB | Output is correct |
3 | Correct | 15 ms | 23836 KB | Output is correct |
4 | Correct | 16 ms | 23788 KB | Output is correct |
5 | Correct | 17 ms | 23912 KB | Output is correct |
6 | Correct | 15 ms | 23772 KB | Output is correct |
7 | Correct | 15 ms | 23784 KB | Output is correct |
8 | Correct | 15 ms | 23756 KB | Output is correct |
9 | Correct | 15 ms | 23828 KB | Output is correct |
10 | Correct | 15 ms | 23784 KB | Output is correct |
11 | Correct | 15 ms | 23756 KB | Output is correct |
12 | Correct | 15 ms | 23756 KB | Output is correct |
13 | Correct | 15 ms | 23796 KB | Output is correct |
14 | Correct | 17 ms | 23740 KB | Output is correct |
15 | Correct | 15 ms | 23756 KB | Output is correct |
16 | Correct | 15 ms | 23756 KB | Output is correct |
17 | Correct | 17 ms | 24064 KB | Output is correct |
18 | Correct | 17 ms | 24140 KB | Output is correct |
19 | Correct | 18 ms | 24152 KB | Output is correct |
20 | Correct | 18 ms | 24060 KB | Output is correct |
21 | Correct | 18 ms | 24140 KB | Output is correct |
22 | Correct | 18 ms | 24088 KB | Output is correct |
23 | Correct | 18 ms | 24036 KB | Output is correct |
24 | Correct | 193 ms | 50468 KB | Output is correct |
25 | Correct | 275 ms | 60984 KB | Output is correct |
26 | Correct | 207 ms | 50648 KB | Output is correct |
27 | Correct | 284 ms | 65832 KB | Output is correct |
28 | Correct | 274 ms | 52156 KB | Output is correct |
29 | Correct | 193 ms | 51652 KB | Output is correct |
30 | Correct | 467 ms | 54256 KB | Output is correct |
31 | Correct | 125 ms | 44288 KB | Output is correct |
32 | Correct | 101 ms | 35216 KB | Output is correct |
33 | Correct | 342 ms | 52376 KB | Output is correct |
34 | Correct | 390 ms | 56220 KB | Output is correct |
35 | Correct | 411 ms | 47684 KB | Output is correct |
36 | Correct | 474 ms | 47776 KB | Output is correct |
37 | Correct | 227 ms | 53604 KB | Output is correct |
38 | Correct | 301 ms | 68836 KB | Output is correct |
39 | Correct | 361 ms | 66068 KB | Output is correct |
40 | Correct | 230 ms | 56804 KB | Output is correct |
41 | Correct | 15 ms | 23756 KB | Output is correct |
42 | Correct | 500 ms | 57408 KB | Output is correct |
43 | Correct | 349 ms | 55200 KB | Output is correct |
44 | Correct | 500 ms | 59188 KB | Output is correct |
45 | Correct | 469 ms | 51012 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 17 ms | 23756 KB | Output is correct |
2 | Correct | 15 ms | 23792 KB | Output is correct |
3 | Correct | 15 ms | 23836 KB | Output is correct |
4 | Correct | 16 ms | 23788 KB | Output is correct |
5 | Correct | 17 ms | 23912 KB | Output is correct |
6 | Correct | 15 ms | 23772 KB | Output is correct |
7 | Correct | 15 ms | 23784 KB | Output is correct |
8 | Correct | 15 ms | 23756 KB | Output is correct |
9 | Correct | 15 ms | 23828 KB | Output is correct |
10 | Correct | 15 ms | 23784 KB | Output is correct |
11 | Correct | 15 ms | 23756 KB | Output is correct |
12 | Correct | 15 ms | 23756 KB | Output is correct |
13 | Correct | 15 ms | 23796 KB | Output is correct |
14 | Correct | 17 ms | 23740 KB | Output is correct |
15 | Correct | 15 ms | 23756 KB | Output is correct |
16 | Correct | 15 ms | 23756 KB | Output is correct |
17 | Correct | 17 ms | 24064 KB | Output is correct |
18 | Correct | 17 ms | 24140 KB | Output is correct |
19 | Correct | 18 ms | 24152 KB | Output is correct |
20 | Correct | 18 ms | 24060 KB | Output is correct |
21 | Correct | 18 ms | 24140 KB | Output is correct |
22 | Correct | 18 ms | 24088 KB | Output is correct |
23 | Correct | 18 ms | 24036 KB | Output is correct |
24 | Correct | 193 ms | 50468 KB | Output is correct |
25 | Correct | 275 ms | 60984 KB | Output is correct |
26 | Correct | 207 ms | 50648 KB | Output is correct |
27 | Correct | 284 ms | 65832 KB | Output is correct |
28 | Correct | 274 ms | 52156 KB | Output is correct |
29 | Correct | 193 ms | 51652 KB | Output is correct |
30 | Correct | 467 ms | 54256 KB | Output is correct |
31 | Correct | 125 ms | 44288 KB | Output is correct |
32 | Correct | 101 ms | 35216 KB | Output is correct |
33 | Correct | 342 ms | 52376 KB | Output is correct |
34 | Correct | 390 ms | 56220 KB | Output is correct |
35 | Correct | 411 ms | 47684 KB | Output is correct |
36 | Correct | 474 ms | 47776 KB | Output is correct |
37 | Correct | 227 ms | 53604 KB | Output is correct |
38 | Correct | 301 ms | 68836 KB | Output is correct |
39 | Correct | 361 ms | 66068 KB | Output is correct |
40 | Correct | 230 ms | 56804 KB | Output is correct |
41 | Correct | 15 ms | 23756 KB | Output is correct |
42 | Correct | 500 ms | 57408 KB | Output is correct |
43 | Correct | 349 ms | 55200 KB | Output is correct |
44 | Correct | 500 ms | 59188 KB | Output is correct |
45 | Correct | 469 ms | 51012 KB | Output is correct |
46 | Correct | 1124 ms | 174036 KB | Output is correct |
47 | Correct | 1577 ms | 250168 KB | Output is correct |
48 | Correct | 1840 ms | 236480 KB | Output is correct |
49 | Correct | 1121 ms | 189680 KB | Output is correct |
50 | Correct | 3194 ms | 191804 KB | Output is correct |
51 | Correct | 2050 ms | 178884 KB | Output is correct |
52 | Correct | 2739 ms | 194980 KB | Output is correct |
53 | Correct | 3004 ms | 160320 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 293 ms | 64824 KB | Output is correct |
2 | Correct | 251 ms | 56800 KB | Output is correct |
3 | Correct | 223 ms | 53880 KB | Output is correct |
4 | Correct | 280 ms | 61252 KB | Output is correct |
5 | Correct | 16 ms | 23756 KB | Output is correct |
6 | Correct | 256 ms | 55452 KB | Output is correct |
7 | Correct | 121 ms | 40632 KB | Output is correct |
8 | Correct | 124 ms | 37084 KB | Output is correct |
9 | Correct | 210 ms | 54804 KB | Output is correct |
10 | Correct | 245 ms | 53184 KB | Output is correct |
11 | Correct | 167 ms | 48116 KB | Output is correct |
12 | Correct | 17 ms | 23756 KB | Output is correct |
13 | Correct | 15 ms | 23792 KB | Output is correct |
14 | Correct | 15 ms | 23836 KB | Output is correct |
15 | Correct | 16 ms | 23788 KB | Output is correct |
16 | Correct | 17 ms | 23912 KB | Output is correct |
17 | Correct | 15 ms | 23772 KB | Output is correct |
18 | Correct | 15 ms | 23784 KB | Output is correct |
19 | Correct | 15 ms | 23756 KB | Output is correct |
20 | Correct | 15 ms | 23828 KB | Output is correct |
21 | Correct | 15 ms | 23784 KB | Output is correct |
22 | Correct | 15 ms | 23756 KB | Output is correct |
23 | Correct | 15 ms | 23756 KB | Output is correct |
24 | Correct | 15 ms | 23796 KB | Output is correct |
25 | Correct | 17 ms | 23740 KB | Output is correct |
26 | Correct | 15 ms | 23756 KB | Output is correct |
27 | Correct | 15 ms | 23756 KB | Output is correct |
28 | Correct | 17 ms | 24064 KB | Output is correct |
29 | Correct | 17 ms | 24140 KB | Output is correct |
30 | Correct | 18 ms | 24152 KB | Output is correct |
31 | Correct | 18 ms | 24060 KB | Output is correct |
32 | Correct | 18 ms | 24140 KB | Output is correct |
33 | Correct | 18 ms | 24088 KB | Output is correct |
34 | Correct | 18 ms | 24036 KB | Output is correct |
35 | Correct | 193 ms | 50468 KB | Output is correct |
36 | Correct | 275 ms | 60984 KB | Output is correct |
37 | Correct | 207 ms | 50648 KB | Output is correct |
38 | Correct | 284 ms | 65832 KB | Output is correct |
39 | Correct | 274 ms | 52156 KB | Output is correct |
40 | Correct | 193 ms | 51652 KB | Output is correct |
41 | Correct | 467 ms | 54256 KB | Output is correct |
42 | Correct | 125 ms | 44288 KB | Output is correct |
43 | Correct | 101 ms | 35216 KB | Output is correct |
44 | Correct | 342 ms | 52376 KB | Output is correct |
45 | Correct | 390 ms | 56220 KB | Output is correct |
46 | Correct | 411 ms | 47684 KB | Output is correct |
47 | Correct | 474 ms | 47776 KB | Output is correct |
48 | Correct | 227 ms | 53604 KB | Output is correct |
49 | Correct | 301 ms | 68836 KB | Output is correct |
50 | Correct | 361 ms | 66068 KB | Output is correct |
51 | Correct | 230 ms | 56804 KB | Output is correct |
52 | Correct | 15 ms | 23756 KB | Output is correct |
53 | Correct | 500 ms | 57408 KB | Output is correct |
54 | Correct | 349 ms | 55200 KB | Output is correct |
55 | Correct | 500 ms | 59188 KB | Output is correct |
56 | Correct | 469 ms | 51012 KB | Output is correct |
57 | Correct | 280 ms | 63392 KB | Output is correct |
58 | Correct | 236 ms | 59820 KB | Output is correct |
59 | Correct | 262 ms | 57836 KB | Output is correct |
60 | Correct | 361 ms | 67032 KB | Output is correct |
61 | Correct | 438 ms | 54100 KB | Output is correct |
62 | Correct | 16 ms | 23780 KB | Output is correct |
63 | Correct | 505 ms | 57424 KB | Output is correct |
64 | Correct | 347 ms | 55056 KB | Output is correct |
65 | Correct | 414 ms | 56124 KB | Output is correct |
66 | Correct | 452 ms | 50996 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 293 ms | 64824 KB | Output is correct |
2 | Correct | 251 ms | 56800 KB | Output is correct |
3 | Correct | 223 ms | 53880 KB | Output is correct |
4 | Correct | 280 ms | 61252 KB | Output is correct |
5 | Correct | 16 ms | 23756 KB | Output is correct |
6 | Correct | 256 ms | 55452 KB | Output is correct |
7 | Correct | 121 ms | 40632 KB | Output is correct |
8 | Correct | 124 ms | 37084 KB | Output is correct |
9 | Correct | 210 ms | 54804 KB | Output is correct |
10 | Correct | 245 ms | 53184 KB | Output is correct |
11 | Correct | 167 ms | 48116 KB | Output is correct |
12 | Correct | 17 ms | 23756 KB | Output is correct |
13 | Correct | 15 ms | 23792 KB | Output is correct |
14 | Correct | 15 ms | 23836 KB | Output is correct |
15 | Correct | 16 ms | 23788 KB | Output is correct |
16 | Correct | 17 ms | 23912 KB | Output is correct |
17 | Correct | 15 ms | 23772 KB | Output is correct |
18 | Correct | 15 ms | 23784 KB | Output is correct |
19 | Correct | 15 ms | 23756 KB | Output is correct |
20 | Correct | 15 ms | 23828 KB | Output is correct |
21 | Correct | 15 ms | 23784 KB | Output is correct |
22 | Correct | 15 ms | 23756 KB | Output is correct |
23 | Correct | 15 ms | 23756 KB | Output is correct |
24 | Correct | 15 ms | 23796 KB | Output is correct |
25 | Correct | 17 ms | 23740 KB | Output is correct |
26 | Correct | 15 ms | 23756 KB | Output is correct |
27 | Correct | 15 ms | 23756 KB | Output is correct |
28 | Correct | 17 ms | 24064 KB | Output is correct |
29 | Correct | 17 ms | 24140 KB | Output is correct |
30 | Correct | 18 ms | 24152 KB | Output is correct |
31 | Correct | 18 ms | 24060 KB | Output is correct |
32 | Correct | 18 ms | 24140 KB | Output is correct |
33 | Correct | 18 ms | 24088 KB | Output is correct |
34 | Correct | 18 ms | 24036 KB | Output is correct |
35 | Correct | 193 ms | 50468 KB | Output is correct |
36 | Correct | 275 ms | 60984 KB | Output is correct |
37 | Correct | 207 ms | 50648 KB | Output is correct |
38 | Correct | 284 ms | 65832 KB | Output is correct |
39 | Correct | 274 ms | 52156 KB | Output is correct |
40 | Correct | 193 ms | 51652 KB | Output is correct |
41 | Correct | 467 ms | 54256 KB | Output is correct |
42 | Correct | 125 ms | 44288 KB | Output is correct |
43 | Correct | 101 ms | 35216 KB | Output is correct |
44 | Correct | 342 ms | 52376 KB | Output is correct |
45 | Correct | 390 ms | 56220 KB | Output is correct |
46 | Correct | 411 ms | 47684 KB | Output is correct |
47 | Correct | 474 ms | 47776 KB | Output is correct |
48 | Correct | 227 ms | 53604 KB | Output is correct |
49 | Correct | 301 ms | 68836 KB | Output is correct |
50 | Correct | 361 ms | 66068 KB | Output is correct |
51 | Correct | 230 ms | 56804 KB | Output is correct |
52 | Correct | 15 ms | 23756 KB | Output is correct |
53 | Correct | 500 ms | 57408 KB | Output is correct |
54 | Correct | 349 ms | 55200 KB | Output is correct |
55 | Correct | 500 ms | 59188 KB | Output is correct |
56 | Correct | 469 ms | 51012 KB | Output is correct |
57 | Correct | 1124 ms | 174036 KB | Output is correct |
58 | Correct | 1577 ms | 250168 KB | Output is correct |
59 | Correct | 1840 ms | 236480 KB | Output is correct |
60 | Correct | 1121 ms | 189680 KB | Output is correct |
61 | Correct | 3194 ms | 191804 KB | Output is correct |
62 | Correct | 2050 ms | 178884 KB | Output is correct |
63 | Correct | 2739 ms | 194980 KB | Output is correct |
64 | Correct | 3004 ms | 160320 KB | Output is correct |
65 | Correct | 280 ms | 63392 KB | Output is correct |
66 | Correct | 236 ms | 59820 KB | Output is correct |
67 | Correct | 262 ms | 57836 KB | Output is correct |
68 | Correct | 361 ms | 67032 KB | Output is correct |
69 | Correct | 438 ms | 54100 KB | Output is correct |
70 | Correct | 16 ms | 23780 KB | Output is correct |
71 | Correct | 505 ms | 57424 KB | Output is correct |
72 | Correct | 347 ms | 55056 KB | Output is correct |
73 | Correct | 414 ms | 56124 KB | Output is correct |
74 | Correct | 452 ms | 50996 KB | Output is correct |
75 | Correct | 1527 ms | 221032 KB | Output is correct |
76 | Correct | 1290 ms | 203252 KB | Output is correct |
77 | Correct | 1302 ms | 191640 KB | Output is correct |
78 | Correct | 1972 ms | 237676 KB | Output is correct |
79 | Correct | 3271 ms | 192568 KB | Output is correct |
80 | Correct | 2286 ms | 176632 KB | Output is correct |
81 | Correct | 2544 ms | 180372 KB | Output is correct |
82 | Correct | 3118 ms | 159440 KB | Output is correct |
83 | Correct | 3163 ms | 178164 KB | Output is correct |