提出 #60158324


ソースコード 拡げる

#include<bits/stdc++.h>
#define lc(x) (x<<1)
#define rc(x) (lc(x)|1)
using namespace std;
typedef long long ll;
const ll N = 18,M = 1<<N,INF = 1e18;
template<typename T>void tomin(T& x,T y){x = min(x,y);}
template<typename T>void tomax(T& x,T y){x = max(x,y);}
//
int n,U,s[M],t[M];

ll vs[M<<2],vt[M<<2],lim[M<<2],ans;
void dfs(int x,int L,int R){
    if(L == R-1){
        vs[x] = s[L],vt[x] = t[L]; lim[x] = 1;
        return;
    }
    int mid = (L+R)/2;
    int p = lc(x),q = rc(x);
    dfs(p,L,mid); dfs(q,mid,R);
    if(max(vs[p],vs[q]) <= min(vt[p],vt[q])){
        vs[x] = max(vs[p],vs[q]),vt[x] = max(vt[p],vt[q]);
        lim[x] = max(lim[p],lim[q]); tomax(lim[x],min(vs[p],vs[q]));
    }else{
        ans += max(vs[p],vs[q]) - min(vt[p],vt[q]);
        vs[x] = min(vt[p],vt[q]),vt[x] = max(vt[p],vt[q]);
        tomax(vs[x],max(lim[p],lim[q]));
        lim[x] = max(lim[p],lim[q]); tomax(lim[x],min(vs[p],vs[q]));
    }
}

int main(){
    ios::sync_with_stdio(false); cin.tie(0);
    cin>>n; U = (1<<n);
    for(int i=0;i<U;i++)cin>>s[i]>>t[i];
    dfs(1,0,U);
    cout<<ans<<endl;
    return 0;
}

提出情報

提出日時
問題 A - Schedule Optimization
ユーザ Crying
言語 C++ 20 (gcc 12.2)
得点 0
コード長 1147 Byte
結果 WA
実行時間 36 ms
メモリ 17960 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 0 / 900
結果
AC × 3
AC × 19
WA × 34
セット名 テストケース
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_srand_00.txt, 01_srand_01.txt, 01_srand_02.txt, 01_srand_03.txt, 01_srand_04.txt, 01_srand_05.txt, 01_srand_06.txt, 01_srand_07.txt, 01_srand_08.txt, 01_srand_09.txt, 02_lrand_00.txt, 02_lrand_01.txt, 02_lrand_02.txt, 02_lrand_03.txt, 02_lrand_04.txt, 02_lrand_05.txt, 02_lrand_06.txt, 02_lrand_07.txt, 02_lrand_08.txt, 02_lrand_09.txt, 02_lrand_10.txt, 02_lrand_11.txt, 02_lrand_12.txt, 02_lrand_13.txt, 02_lrand_14.txt, 02_lrand_15.txt, 02_lrand_16.txt, 02_lrand_17.txt, 02_lrand_18.txt, 02_lrand_19.txt, 03_short_00.txt, 03_short_01.txt, 03_short_02.txt, 03_short_03.txt, 03_short_04.txt, 03_short_05.txt, 03_short_06.txt, 03_short_07.txt, 04_hand_00.txt, 04_hand_01.txt, 04_hand_02.txt, 04_hand_03.txt, 04_hand_04.txt, 04_hand_05.txt, 04_hand_06.txt, 04_hand_07.txt, 05_same_00.txt, 05_same_01.txt, 05_same_02.txt, 05_same_03.txt
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 1 ms 3484 KiB
00_sample_01.txt AC 1 ms 3492 KiB
00_sample_02.txt AC 1 ms 3552 KiB
01_srand_00.txt AC 1 ms 3428 KiB
01_srand_01.txt AC 1 ms 3488 KiB
01_srand_02.txt AC 1 ms 3548 KiB
01_srand_03.txt AC 1 ms 3488 KiB
01_srand_04.txt AC 1 ms 3488 KiB
01_srand_05.txt AC 1 ms 3480 KiB
01_srand_06.txt AC 1 ms 3348 KiB
01_srand_07.txt AC 1 ms 3408 KiB
01_srand_08.txt AC 1 ms 3548 KiB
01_srand_09.txt AC 1 ms 3548 KiB
02_lrand_00.txt WA 35 ms 17808 KiB
02_lrand_01.txt WA 35 ms 17680 KiB
02_lrand_02.txt WA 35 ms 17764 KiB
02_lrand_03.txt WA 35 ms 17876 KiB
02_lrand_04.txt WA 35 ms 17800 KiB
02_lrand_05.txt WA 35 ms 17868 KiB
02_lrand_06.txt WA 35 ms 17812 KiB
02_lrand_07.txt WA 35 ms 17876 KiB
02_lrand_08.txt WA 36 ms 17960 KiB
02_lrand_09.txt WA 36 ms 17740 KiB
02_lrand_10.txt WA 18 ms 10668 KiB
02_lrand_11.txt WA 18 ms 10668 KiB
02_lrand_12.txt WA 18 ms 10656 KiB
02_lrand_13.txt WA 18 ms 10800 KiB
02_lrand_14.txt WA 18 ms 10636 KiB
02_lrand_15.txt WA 18 ms 10716 KiB
02_lrand_16.txt WA 18 ms 10672 KiB
02_lrand_17.txt WA 18 ms 10604 KiB
02_lrand_18.txt WA 18 ms 10716 KiB
02_lrand_19.txt WA 18 ms 10668 KiB
03_short_00.txt WA 17 ms 10588 KiB
03_short_01.txt WA 35 ms 17828 KiB
03_short_02.txt WA 34 ms 17792 KiB
03_short_03.txt WA 34 ms 17824 KiB
03_short_04.txt WA 18 ms 10792 KiB
03_short_05.txt WA 9 ms 7136 KiB
03_short_06.txt WA 34 ms 17824 KiB
03_short_07.txt WA 9 ms 7052 KiB
04_hand_00.txt AC 27 ms 17768 KiB
04_hand_01.txt AC 14 ms 10596 KiB
04_hand_02.txt WA 35 ms 17740 KiB
04_hand_03.txt WA 34 ms 17808 KiB
04_hand_04.txt WA 36 ms 17880 KiB
04_hand_05.txt WA 35 ms 17800 KiB
04_hand_06.txt WA 35 ms 17768 KiB
04_hand_07.txt WA 35 ms 17684 KiB
05_same_00.txt AC 1 ms 3480 KiB
05_same_01.txt AC 1 ms 3404 KiB
05_same_02.txt AC 1 ms 3464 KiB
05_same_03.txt AC 34 ms 17744 KiB