# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
29504 | 2017-07-19T14:16:36 Z | TAMREF | 막대기 (KOI13_game) | C++11 | 29 ms | 5144 KB |
#include <bits/stdc++.h> using namespace std; const int mx=200005; typedef long long ll; int coo[mx], comp[mx]; int L, N; ll dp[mx],z,w,e; int main(){ scanf("%d%d",&N,&L); for(int i=0;i<N;i++) scanf("%d%d",&coo[i],&coo[i+N]); memcpy(comp,coo,sizeof(coo)); sort(comp,comp+N); sort(comp+N,comp+(N<<1)); int u=unique(comp,comp+N)-comp, v=unique(comp+N,comp+(N<<1))-comp; for(int i=0;i<N;i++){ coo[i]=lower_bound(comp,comp+u,coo[i])-comp; coo[i+N]=lower_bound(comp+N,comp+v,coo[i+N])-comp; } for(int i=0;i<N;i++){ e=0LL+abs(comp[coo[i]]-comp[coo[i+N]])+L; z=dp[coo[i]], w=dp[coo[i+N]]; dp[coo[i]]=max(z,w+e); dp[coo[i+N]]=max(w,z+e); } printf("%lld\n",*max_element(dp,dp+2*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 | 29 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 | 6 ms | 5144 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |