結果

問題 No.1375 Divide and Update
ユーザー 👑 NachiaNachia
提出日時 2021-02-05 22:30:10
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 53 ms / 2,000 ms
コード長 690 bytes
コンパイル時間 1,852 ms
コンパイル使用メモリ 197,784 KB
実行使用メモリ 8,272 KB
最終ジャッジ日時 2023-09-15 08:56:30
合計ジャッジ時間 4,520 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,552 KB
testcase_01 AC 2 ms
5,628 KB
testcase_02 AC 2 ms
5,812 KB
testcase_03 AC 2 ms
5,548 KB
testcase_04 AC 2 ms
5,608 KB
testcase_05 AC 2 ms
5,596 KB
testcase_06 AC 2 ms
5,656 KB
testcase_07 AC 2 ms
5,640 KB
testcase_08 AC 2 ms
5,516 KB
testcase_09 AC 2 ms
5,748 KB
testcase_10 AC 45 ms
7,828 KB
testcase_11 AC 42 ms
7,600 KB
testcase_12 AC 23 ms
6,692 KB
testcase_13 AC 19 ms
6,696 KB
testcase_14 AC 51 ms
8,224 KB
testcase_15 AC 52 ms
8,208 KB
testcase_16 AC 51 ms
8,272 KB
testcase_17 AC 51 ms
8,220 KB
testcase_18 AC 53 ms
8,192 KB
testcase_19 AC 52 ms
8,268 KB
testcase_20 AC 40 ms
8,212 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using LL=long long;
using ULL=unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)

int N;
LL X,Y;
LL A[200000];
LL ansl[200000];
LL ansr[200000];

int main(){
  scanf("%d%lld%lld",&N,&X,&Y);
  rep(i,N){ int a; scanf("%d",&a); A[i]=a; }

  LL minl,S;
  minl=S=0;
  rep(i,N-2){
    S+=X-A[i];
    ansl[i]=S-minl;
    if(i!=0) ansl[i] = max(ansl[i-1],ansl[i]);
    minl=min(minl,S);
  }
  minl=S=0;
  for(int i=N-2; i>=1; i--){
    S+=Y-A[i+1];
    ansr[i-1]=S-minl;
    if(i!=N-2) ansr[i-1] = max(ansr[i],ansr[i-1]);
    minl=min(minl,S);
  }

  S=0;
  rep(i,N) S+=A[i];
  rep(i,N-2) printf("%lld\n",ansl[i]+ansr[i]+S);
  return 0;
}

0