結果

問題 No.1375 Divide and Update
ユーザー 👑 NachiaNachia
提出日時 2021-02-05 22:29:33
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 690 bytes
コンパイル時間 2,121 ms
コンパイル使用メモリ 197,304 KB
実行使用メモリ 5,508 KB
最終ジャッジ日時 2023-09-15 08:55:57
合計ジャッジ時間 4,893 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 RE -
testcase_11 RE -
testcase_12 AC 24 ms
5,508 KB
testcase_13 AC 21 ms
5,196 KB
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 WA -
権限があれば一括ダウンロードができます

ソースコード

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[100000];
LL ansl[100000];
LL ansr[100000];

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