# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
20210 | 2016-04-10T08:37:35 Z | myduddlf | 막대기 (KOI13_game) | C++ | 96 ms | 19 KB |
#include <stdio.h> #include <math.h> #include <algorithm> using namespace std; const int N=111111; struct Stick{int t,d,s;}; int n,l; Stick a[N]; int t_x[N],d_x[N]; long long e[N][2],v1,v2,ans; int cmp(const Stick &p,const Stick &q){return p.t<q.t||(p.t==q.t&&p.d<q.d);} int main() { int i,v; scanf("%d%d",&n,&l); for(i=0;i<n;++i) { scanf("%d%d",&a[i].t,&a[i].d); a[i].s=abs(a[i].t-a[i].d)+l; t_x[i]=a[i].t; d_x[i]=a[i].d; } sort(t_x,t_x+n); sort(d_x,d_x+n); for(i=0;i<n;++i) { a[i].t=lower_bound(t_x,t_x+n,a[i].t)-t_x; a[i].d=lower_bound(d_x,d_x+n,a[i].d)-d_x; } sort(a,a+n,cmp); for(i=0;i<n;++i) { v1=e[a[i].t][0]+a[i].s; v2=e[a[i].d][1]+a[i].s; if(v1>e[a[i].d][1]) e[a[i].d][1]=v1; if(v2>e[a[i].t][0]) e[a[i].t][0]=v2; if(v1>ans) ans=v1; if(v2>ans) ans=v2; } printf("%lld\n",ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 0 KB | Output is correct |
2 | Correct | 2 ms | 0 KB | Output is correct |
3 | Correct | 2 ms | 0 KB | Output is correct |
4 | Correct | 1 ms | 0 KB | Output is correct |
5 | Correct | 1 ms | 0 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 39 ms | 2 KB | Output is correct |
2 | Correct | 38 ms | 2 KB | Output is correct |
3 | Correct | 84 ms | 5 KB | Output is correct |
4 | Correct | 80 ms | 6 KB | Output is correct |
5 | Correct | 82 ms | 7 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 7 KB | Output is correct |
2 | Correct | 1 ms | 7 KB | Output is correct |
3 | Correct | 1 ms | 7 KB | Output is correct |
4 | Correct | 1 ms | 7 KB | Output is correct |
5 | Correct | 1 ms | 7 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 7 KB | Output is correct |
2 | Correct | 2 ms | 7 KB | Output is correct |
3 | Correct | 2 ms | 7 KB | Output is correct |
4 | Correct | 2 ms | 7 KB | Output is correct |
5 | Correct | 2 ms | 7 KB | Output is correct |
6 | Correct | 2 ms | 7 KB | Output is correct |
7 | Correct | 2 ms | 7 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 7 KB | Output is correct |
2 | Correct | 9 ms | 7 KB | Output is correct |
3 | Correct | 39 ms | 7 KB | Output is correct |
4 | Correct | 91 ms | 9 KB | Output is correct |
5 | Correct | 94 ms | 11 KB | Output is correct |
6 | Correct | 86 ms | 13 KB | Output is correct |
7 | Correct | 96 ms | 14 KB | Output is correct |
8 | Correct | 74 ms | 16 KB | Output is correct |
9 | Correct | 9 ms | 16 KB | Output is correct |
10 | Correct | 9 ms | 16 KB | Output is correct |
11 | Correct | 93 ms | 18 KB | Output is correct |
12 | Correct | 94 ms | 19 KB | Output is correct |