結果

問題 No.1375 Divide and Update
ユーザー ocvret_ocvret_
提出日時 2021-02-05 22:15:58
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 109 ms / 2,000 ms
コード長 765 bytes
コンパイル時間 1,887 ms
コンパイル使用メモリ 167,048 KB
実行使用メモリ 7,872 KB
最終ジャッジ日時 2023-09-15 08:31:17
合計ジャッジ時間 5,300 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,384 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 89 ms
6,916 KB
testcase_11 AC 82 ms
6,736 KB
testcase_12 AC 45 ms
5,212 KB
testcase_13 AC 38 ms
4,548 KB
testcase_14 AC 101 ms
7,844 KB
testcase_15 AC 102 ms
7,728 KB
testcase_16 AC 102 ms
7,760 KB
testcase_17 AC 101 ms
7,872 KB
testcase_18 AC 108 ms
7,792 KB
testcase_19 AC 109 ms
7,840 KB
testcase_20 AC 55 ms
7,780 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
// #include<atcoder/all>

using namespace std;
// using namespace atcoder;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007

void kadane(vector<ll> &v,vector<ll> &w,ll k){
  ll res = -1e18;
  ll s = 0;
  rep(i,v.size()){
    s = max(s+k-v[i],k-v[i]);
    res = max(res,s);
    w[i] = res;
  }
}

int main(){
  
  ll n,X,Y;
  cin >> n >> X >> Y;
  vector<ll> a(n),x(n),y(n);
  rep(i,n)cin >> a[i];
  kadane(a,x,X);
  ll s = 0;
  rep(i,n)s += a[i];
  reverse(ALL(a));
  kadane(a,y,Y);
  reverse(ALL(y));
  for(int i = 1;i < n-1;i++){
    ll k = x[i-1] + y[i+1];
    cout << s + k << "\n";
  }


  return 0;
}
0