# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
260920 | 2020-08-11T07:57:08 Z | 문홍윤(#5067) | Harvest (JOI20_harvest) | C++17 | 5000 ms | 183288 KB |
#include <bits/stdc++.h> #define eb emplace_back #define mp make_pair #define F first #define S second using namespace std; typedef long long LL; typedef pair<int, int> pii; typedef pair<LL, LL> pll; typedef pair<int, LL> pil; int n, m, q; LL arr[200010], app[200010], c, l; int st[200010]; pil link[200010]; vector<LL> vct[200010]; vector<pll> vcc[200010]; bool ch[200010], isc; int cut; LL clen, dist[200010]; void dfs(int num, LL d){ if(ch[num]){ cut=num; isc=true; clen=d-dist[num]; return; } dist[num]=d; ch[num]=true; dfs(link[num].F, d+link[num].S); if(isc)vcc[num].eb(clen, d); else vct[num].eb(d); ch[num]=false; dist[num]=0; if(num==cut){ cut=0; clen=0; isc=false; } } int main(){ scanf("%d %d %d %d", &n, &m, &l, &c); for(int i=1; i<=n; i++)scanf("%lld", &arr[i]); for(int i=1; i<=m; i++)scanf("%lld", &app[i]); for(int i=1; i<=m; i++){ int tmp=upper_bound(arr+1, arr+n+1, app[i])-arr-1; if(!tmp)st[i]=n; else st[i]=tmp; } for(int i=1; i<=n; i++){ LL nxt=(arr[i]-(c%l)+l)%l; int tmp=upper_bound(arr+1, arr+n+1, nxt)-arr-1; if(!tmp)tmp=n; LL d=nxt-arr[tmp]; if(d<0)d+=l; d+=c; link[i]=mp(tmp, d); } for(int i=1; i<=m; i++){ LL initd=app[i]-arr[st[i]]; if(initd<0)initd+=l; dfs(st[i], initd); } scanf("%d", &q); for(int i=1; i<=q; i++){ int a; LL t; scanf("%d %lld", &a, &t); LL num=0; for(auto j:vct[a]){ if(j<=t)num++; } for(auto j:vcc[a]){ if(j.S>t)continue; num+=(t-j.S)/j.F+1; } printf("%lld\n", num); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 9728 KB | Output is correct |
2 | Correct | 10 ms | 10112 KB | Output is correct |
3 | Correct | 108 ms | 10232 KB | Output is correct |
4 | Correct | 24 ms | 15616 KB | Output is correct |
5 | Correct | 135 ms | 57848 KB | Output is correct |
6 | Correct | 137 ms | 58104 KB | Output is correct |
7 | Correct | 169 ms | 59768 KB | Output is correct |
8 | Correct | 10 ms | 10112 KB | Output is correct |
9 | Correct | 10 ms | 10112 KB | Output is correct |
10 | Correct | 10 ms | 10112 KB | Output is correct |
11 | Correct | 10 ms | 10112 KB | Output is correct |
12 | Correct | 360 ms | 183288 KB | Output is correct |
13 | Correct | 466 ms | 183288 KB | Output is correct |
14 | Correct | 211 ms | 99868 KB | Output is correct |
15 | Correct | 76 ms | 36216 KB | Output is correct |
16 | Correct | 73 ms | 36472 KB | Output is correct |
17 | Correct | 88 ms | 36032 KB | Output is correct |
18 | Correct | 71 ms | 34808 KB | Output is correct |
19 | Correct | 72 ms | 34424 KB | Output is correct |
20 | Correct | 68 ms | 33764 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 5055 ms | 12220 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 9728 KB | Output is correct |
2 | Correct | 10 ms | 10112 KB | Output is correct |
3 | Correct | 108 ms | 10232 KB | Output is correct |
4 | Correct | 24 ms | 15616 KB | Output is correct |
5 | Correct | 135 ms | 57848 KB | Output is correct |
6 | Correct | 137 ms | 58104 KB | Output is correct |
7 | Correct | 169 ms | 59768 KB | Output is correct |
8 | Correct | 10 ms | 10112 KB | Output is correct |
9 | Correct | 10 ms | 10112 KB | Output is correct |
10 | Correct | 10 ms | 10112 KB | Output is correct |
11 | Correct | 10 ms | 10112 KB | Output is correct |
12 | Correct | 360 ms | 183288 KB | Output is correct |
13 | Correct | 466 ms | 183288 KB | Output is correct |
14 | Correct | 211 ms | 99868 KB | Output is correct |
15 | Correct | 76 ms | 36216 KB | Output is correct |
16 | Correct | 73 ms | 36472 KB | Output is correct |
17 | Correct | 88 ms | 36032 KB | Output is correct |
18 | Correct | 71 ms | 34808 KB | Output is correct |
19 | Correct | 72 ms | 34424 KB | Output is correct |
20 | Correct | 68 ms | 33764 KB | Output is correct |
21 | Execution timed out | 5055 ms | 12220 KB | Time limit exceeded |
22 | Halted | 0 ms | 0 KB | - |