結果

問題 No.1375 Divide and Update
ユーザー ttkkggwwttkkggww
提出日時 2021-02-05 23:19:52
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 350 ms / 2,000 ms
コード長 739 bytes
コンパイル時間 3,049 ms
コンパイル使用メモリ 203,540 KB
実行使用メモリ 9,460 KB
最終ジャッジ日時 2023-09-15 10:50:32
合計ジャッジ時間 8,014 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,388 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 309 ms
8,592 KB
testcase_11 AC 278 ms
8,012 KB
testcase_12 AC 150 ms
5,964 KB
testcase_13 AC 127 ms
5,364 KB
testcase_14 AC 347 ms
9,328 KB
testcase_15 AC 350 ms
9,460 KB
testcase_16 AC 344 ms
9,396 KB
testcase_17 AC 349 ms
9,376 KB
testcase_18 AC 347 ms
9,316 KB
testcase_19 AC 349 ms
9,380 KB
testcase_20 AC 298 ms
9,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
//#include<atcoder/all>
//using namespace atcoder;
using namespace std;
using ll = long long;

int main(){
	ll n,x,y;
	cin >> n >> x >> y;

	vector<ll> a(n);
	for(auto &i:a)cin >> i;
	vector<ll> ans(n);
	for(int i = 0;i<2;i++){
		vector<ll> b = a;
		for(auto &i:b)  i = x-i;
		int l = 0,r = 1;
		vector<ll> bsum(n+1,0);
		for(int i = 0;i<n;i++)bsum[i+1] = b[i] + bsum[i];
		ll mn = 0;
		ll now = bsum[1];
		for(int i = 1;i<n-1;i++){
			now = max(now,bsum[i]-mn);
			ans[i] += now;
			mn = min(bsum[i],mn);
		}
		reverse(ans.begin(),ans.end());
		reverse(a.begin(),a.end());
		swap(x,y);
	}
	ll sum = 0;
	for(auto &i:a)sum += i;
	//reverse(ans.begin(),ans.end());
	for(int i = 1;i<n-1;i++)cout<<sum+ans[i]<<endl;

}
0