結果

問題 No.409 ダイエット
ユーザー rapurasurapurasu
提出日時 2017-06-15 13:19:21
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,105 bytes
コンパイル時間 1,585 ms
コンパイル使用メモリ 168,784 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2023-10-25 06:47:36
合計ジャッジ時間 8,464 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
9,772 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 3 ms
9,772 KB
testcase_04 WA -
testcase_05 AC 4 ms
9,772 KB
testcase_06 AC 4 ms
9,772 KB
testcase_07 AC 3 ms
9,772 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 3 ms
9,772 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 3 ms
9,772 KB
testcase_16 AC 4 ms
9,772 KB
testcase_17 AC 3 ms
9,772 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 3 ms
9,772 KB
testcase_24 AC 4 ms
9,772 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 3 ms
9,772 KB
testcase_28 AC 3 ms
9,772 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 3 ms
9,772 KB
testcase_32 WA -
testcase_33 AC 3 ms
9,772 KB
testcase_34 AC 3 ms
9,772 KB
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
testcase_56 AC 55 ms
10,584 KB
testcase_57 WA -
testcase_58 WA -
testcase_59 WA -
testcase_60 WA -
testcase_61 WA -
testcase_62 WA -
testcase_63 WA -
testcase_64 WA -
testcase_65 WA -
testcase_66 WA -
testcase_67 WA -
testcase_68 WA -
testcase_69 WA -
testcase_70 WA -
testcase_71 WA -
testcase_72 WA -
testcase_73 WA -
testcase_74 WA -
testcase_75 WA -
testcase_76 WA -
testcase_77 WA -
testcase_78 WA -
testcase_79 WA -
testcase_80 WA -
testcase_81 WA -
testcase_82 WA -
testcase_83 WA -
testcase_84 WA -
testcase_85 WA -
testcase_86 WA -
testcase_87 WA -
testcase_88 WA -
testcase_89 WA -
testcase_90 WA -
testcase_91 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

 #include<bits/stdc++.h>
 using namespace std;
#define INF 1000000000
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
typedef long long LL;
int N,A,B,W;
int D[300011];
int sum[300011];
LL que[300011];
LL day[300011];

void calc_sum(){
     sum[0]=0;
     REP(i,300010){
        sum[i+1]=sum[i]-A+B*(i+1);
     }
}

LL change(LL q1,LL d1,LL q2,LL d2){
   q1+=sum[(d2-d1)];
   if(B<=A)return 1e12;
   if(B==0)return 1e12;
   LL btk=q2-q1;
   
   return btk/(B*(d2-d1))+1+d2;
}

int main(){
    cin>>N>>A>>B>>W;
    calc_sum();
    REP(i,N){
       cin>>D[i+1];
    }
   /* REP(i,N+1){
        printf("sum[%d]=%d",i,sum[i]);
    }*/
    que[0]=0;
    day[0]=0;
    int l=0,r=1;
    REP(i,N+1){
        if(i==0)continue;
        int n_day=i;
        //先頭の更新
        while(1){
           if(r-l==1)break;//queに要素が1つ
           if(change(que[l],day[l],que[l+1],day[l+1])<n_day){
              //printf("change%d\n",change(que[l],day[l],que[l+1],day[l+1]));
             // printf("l,que=%d,day=%d,\n",que[l],day[l]);
              l++;

           }else{
              //printf("change%d\n",change(que[l],day[l],que[l+1],day[l+1]));
              //printf("l,day=%dday2=%d,\n",day[l],day[l+1]);
              break;
           }
        }
        //後ろに追加
        que[r]=que[l]+sum[n_day-day[l]-1]+D[n_day];//これを後ろに追加
        day[r]=n_day;
       // cout<<"ok"<<endl;
        //後ろの更新
        while(1){
            if(r-l==0)break;
            if(r-l==1)break;
            if(change(que[r-1],day[r-1],que[r],day[r])<change(que[r-2],day[r-2],que[r-1],day[r-1])){
               //printf("r,que=%d,day=%d\n",que[r-1],day[r-1]);
               que[r-1]=que[r];
               day[r-1]=day[r];
               r--;
            }else{
               break;
            }
        }
        r++;
    }
    //残ったもので計算
    LL ans=1e17;
    //printf("l=%d,r=%d\n",l,r);
    for(int i=l;i<r;i++){
        //cout<<que[i]<<" "<<day[i]<<endl;
        ans=min(ans,que[i]+sum[N-day[i]]);
    }
    //cout<<ans<<endl;
    cout<<ans+W<<endl;
    return 0;
}
0