省略
省略
C++に変換後のコードはこちら
int N, L[1d5], R[1d5];
{
int res = 0, mn, mx, all, k, x, y;
rd(N,(L,R)(N));
rep(i,N) R[i] *= -1;
sortA(N,L,R);
rep(i,N) R[i] *= -1;
mn = max(L(N));
mx = min(R(N));
all = max(mx - mn + 1, 0);
rep(i,N) res >?= R[i] - L[i] + 1 + all;
k = 0;
rep(i,N){
while(k > 0 && R[i] <= R[k-1]) k--;
arrInsert(k,k,L,L[i],R,R[i]);
}
N = k;
rep(i,1,N){
x = max(0, R[0] - L[i-1] + 1);
y = max(0, R[i] - L[N-1] + 1);
res >?= x + y;
}
wt(res);
}
Current time: 2024年04月19日12時07分52秒
Last modified: 2019年11月10日18時37分21秒 (by laycrs)
Tags: Competitive_Programming_Incomplete AtCoder AtCoder_Grand_Contest AGC040 AGC_B
トップページに戻る
Logged in as: unknown user (not login)