# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
29703 | 2017-07-20T10:53:06 Z | TAMREF | 막대기 (KOI13_game) | C++11 | 19 ms | 5144 KB |
#include <bits/stdc++.h> using namespace std; const int mx=100005; typedef long long ll; int coo[2][mx], comp[2][mx]; int L, N; ll dp[2][mx],z,w,e; int main(){ scanf("%d%d",&N,&L); for(int i=0;i<N;i++){ scanf("%d %d",&coo[0][i],&coo[1][i]); comp[0][i]=coo[0][i], comp[1][i]=coo[1][i]; } sort(comp[0],comp[0]+N); sort(comp[1],comp[1]+N); int u=unique(comp[0],comp[0]+N)-comp[0], v=unique(comp[1],comp[1]+N)-comp[1]; for(int i=0;i<N;i++){ coo[0][i]=lower_bound(comp[0],comp[0]+u,coo[0][i])-comp[0]; coo[1][i]=lower_bound(comp[1],comp[1]+v,coo[1][i])-comp[1]; } for(int i=0;i<N;i++){ e=llabs((ll)comp[0][coo[0][i]]-comp[1][coo[1][i]])+L; z=dp[0][coo[0][i]], w=dp[1][coo[1][i]]; dp[0][coo[0][i]]=max(z,w+e); dp[1][coo[1][i]]=max(w,z+e); } printf("%lld\n",max(*max_element(dp[0],dp[0]+N),*max_element(dp[1],dp[1]+N))); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 5144 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 19 ms | 5144 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 5144 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 5144 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 5144 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |