# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1119818 | 2024-11-27T13:09:49 Z | onlk97 | Sightseeing in Kyoto (JOI22_kyoto) | C++14 | 31 ms | 5788 KB |
#include <bits/stdc++.h> #define int long long #define x first #define y second #define pb push_back using namespace std; using pii=pair <int,int>; signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); int n,m; cin>>n>>m; int a[n+1],b[m+1]; for (int i=1; i<=n; i++) cin>>a[i]; for (int i=1; i<=m; i++) cin>>b[i]; vector <pii> va,vb; va.pb({1,a[1]}); for (int i=2; i<=n; i++){ while (va.size()>1){ int sz=va.size(); if ((va[sz-1].y-va[sz-2].y)*(i-va[sz-1].x)>=(a[i]-va[sz-1].y)*(va[sz-1].x-va[sz-2].x)) va.pop_back(); else break; } va.pb({i,a[i]}); } vb.pb({1,b[1]}); for (int i=2; i<=m; i++){ while (vb.size()>1){ int sz=vb.size(); if ((vb[sz-1].y-vb[sz-2].y)*(i-vb[sz-1].x)>=(b[i]-vb[sz-1].y)*(vb[sz-1].x-vb[sz-2].x)) vb.pop_back(); else break; } vb.pb({i,b[i]}); } int ans=0,xp=0,yp=0; while (xp!=va.size()-1||yp!=vb.size()-1){ int c; if (xp==va.size()-1) c=1; else if (yp==vb.size()-1) c=0; else if ((va[xp+1].y-va[xp].y)*(vb[yp+1].x-vb[yp].x)>=(vb[yp+1].y-vb[yp].y)*(va[xp+1].x-va[xp].x)) c=1; else c=0; if (c){ ans+=va[xp].y*(vb[yp+1].x-vb[yp].x); yp++; } else { ans+=vb[yp].y*(va[xp+1].x-va[xp].x); xp++; } } cout<<ans<<'\n'; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 1 ms | 596 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 1 ms | 340 KB | Output is correct |
10 | Correct | 1 ms | 596 KB | Output is correct |
11 | Correct | 1 ms | 492 KB | Output is correct |
12 | Correct | 1 ms | 340 KB | Output is correct |
13 | Correct | 1 ms | 340 KB | Output is correct |
14 | Correct | 1 ms | 340 KB | Output is correct |
15 | Correct | 1 ms | 340 KB | Output is correct |
16 | Correct | 1 ms | 340 KB | Output is correct |
17 | Correct | 1 ms | 352 KB | Output is correct |
18 | Correct | 1 ms | 352 KB | Output is correct |
19 | Correct | 1 ms | 352 KB | Output is correct |
20 | Correct | 1 ms | 352 KB | Output is correct |
21 | Correct | 1 ms | 352 KB | Output is correct |
22 | Correct | 1 ms | 352 KB | Output is correct |
23 | Correct | 1 ms | 344 KB | Output is correct |
24 | Correct | 1 ms | 464 KB | Output is correct |
25 | Correct | 1 ms | 344 KB | Output is correct |
26 | Correct | 1 ms | 352 KB | Output is correct |
27 | Correct | 1 ms | 352 KB | Output is correct |
28 | Correct | 1 ms | 464 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 464 KB | Output is correct |
4 | Correct | 6 ms | 1376 KB | Output is correct |
5 | Correct | 8 ms | 1120 KB | Output is correct |
6 | Correct | 4 ms | 608 KB | Output is correct |
7 | Correct | 13 ms | 2804 KB | Output is correct |
8 | Correct | 14 ms | 2788 KB | Output is correct |
9 | Correct | 13 ms | 2668 KB | Output is correct |
10 | Correct | 13 ms | 2792 KB | Output is correct |
11 | Correct | 17 ms | 2656 KB | Output is correct |
12 | Correct | 15 ms | 2656 KB | Output is correct |
13 | Correct | 14 ms | 2912 KB | Output is correct |
14 | Correct | 15 ms | 2660 KB | Output is correct |
15 | Correct | 15 ms | 2908 KB | Output is correct |
16 | Correct | 1 ms | 340 KB | Output is correct |
17 | Correct | 1 ms | 340 KB | Output is correct |
18 | Correct | 1 ms | 508 KB | Output is correct |
19 | Correct | 1 ms | 596 KB | Output is correct |
20 | Correct | 1 ms | 340 KB | Output is correct |
21 | Correct | 1 ms | 340 KB | Output is correct |
22 | Correct | 1 ms | 340 KB | Output is correct |
23 | Correct | 1 ms | 468 KB | Output is correct |
24 | Correct | 1 ms | 340 KB | Output is correct |
25 | Correct | 1 ms | 508 KB | Output is correct |
26 | Correct | 1 ms | 340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 1 ms | 596 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 1 ms | 340 KB | Output is correct |
10 | Correct | 1 ms | 596 KB | Output is correct |
11 | Correct | 1 ms | 492 KB | Output is correct |
12 | Correct | 1 ms | 340 KB | Output is correct |
13 | Correct | 1 ms | 340 KB | Output is correct |
14 | Correct | 1 ms | 340 KB | Output is correct |
15 | Correct | 1 ms | 340 KB | Output is correct |
16 | Correct | 1 ms | 340 KB | Output is correct |
17 | Correct | 1 ms | 352 KB | Output is correct |
18 | Correct | 1 ms | 352 KB | Output is correct |
19 | Correct | 1 ms | 352 KB | Output is correct |
20 | Correct | 1 ms | 352 KB | Output is correct |
21 | Correct | 1 ms | 352 KB | Output is correct |
22 | Correct | 1 ms | 352 KB | Output is correct |
23 | Correct | 1 ms | 344 KB | Output is correct |
24 | Correct | 1 ms | 464 KB | Output is correct |
25 | Correct | 1 ms | 344 KB | Output is correct |
26 | Correct | 1 ms | 352 KB | Output is correct |
27 | Correct | 1 ms | 352 KB | Output is correct |
28 | Correct | 1 ms | 464 KB | Output is correct |
29 | Correct | 1 ms | 348 KB | Output is correct |
30 | Correct | 1 ms | 348 KB | Output is correct |
31 | Correct | 1 ms | 464 KB | Output is correct |
32 | Correct | 6 ms | 1376 KB | Output is correct |
33 | Correct | 8 ms | 1120 KB | Output is correct |
34 | Correct | 4 ms | 608 KB | Output is correct |
35 | Correct | 13 ms | 2804 KB | Output is correct |
36 | Correct | 14 ms | 2788 KB | Output is correct |
37 | Correct | 13 ms | 2668 KB | Output is correct |
38 | Correct | 13 ms | 2792 KB | Output is correct |
39 | Correct | 17 ms | 2656 KB | Output is correct |
40 | Correct | 15 ms | 2656 KB | Output is correct |
41 | Correct | 14 ms | 2912 KB | Output is correct |
42 | Correct | 15 ms | 2660 KB | Output is correct |
43 | Correct | 15 ms | 2908 KB | Output is correct |
44 | Correct | 1 ms | 340 KB | Output is correct |
45 | Correct | 1 ms | 340 KB | Output is correct |
46 | Correct | 1 ms | 508 KB | Output is correct |
47 | Correct | 1 ms | 596 KB | Output is correct |
48 | Correct | 1 ms | 340 KB | Output is correct |
49 | Correct | 1 ms | 340 KB | Output is correct |
50 | Correct | 1 ms | 340 KB | Output is correct |
51 | Correct | 1 ms | 468 KB | Output is correct |
52 | Correct | 1 ms | 340 KB | Output is correct |
53 | Correct | 1 ms | 508 KB | Output is correct |
54 | Correct | 1 ms | 340 KB | Output is correct |
55 | Correct | 10 ms | 1876 KB | Output is correct |
56 | Correct | 1 ms | 504 KB | Output is correct |
57 | Correct | 2 ms | 596 KB | Output is correct |
58 | Correct | 4 ms | 724 KB | Output is correct |
59 | Correct | 26 ms | 3928 KB | Output is correct |
60 | Correct | 19 ms | 3928 KB | Output is correct |
61 | Correct | 30 ms | 3808 KB | Output is correct |
62 | Correct | 23 ms | 3924 KB | Output is correct |
63 | Correct | 30 ms | 5788 KB | Output is correct |
64 | Correct | 31 ms | 3924 KB | Output is correct |
65 | Correct | 20 ms | 3976 KB | Output is correct |
66 | Correct | 20 ms | 3924 KB | Output is correct |
67 | Correct | 20 ms | 3928 KB | Output is correct |