답안 #29504

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
29504 2017-07-19T14:16:36 Z TAMREF 막대기 (KOI13_game) C++11
0 / 100
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

game.cpp: In function 'int main()':
game.cpp:9:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&N,&L);
                        ^
game.cpp:10:57: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=0;i<N;i++) scanf("%d%d",&coo[i],&coo[i+N]);
                                                         ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 5144 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 29 ms 5144 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 5144 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 5144 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 5144 KB Output isn't correct
2 Halted 0 ms 0 KB -