結果

問題 No.1375 Divide and Update
ユーザー poohbearpoohbear
提出日時 2021-02-05 22:18:59
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,619 bytes
コンパイル時間 2,442 ms
コンパイル使用メモリ 201,432 KB
実行使用メモリ 9,436 KB
最終ジャッジ日時 2023-09-15 08:35:13
合計ジャッジ時間 6,985 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
//using namespace atcoder;
using ll = long long;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
typedef vector<vector<int> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a >= b) { a = b; return 1; } return 0; }
const ll INF = 1e18+7;

#define debug(v) cout<<#v<<": ",prt(v);
template <typename A,typename B>
inline void prt(pair<A,B> p){cout<<"("<<p.first<<", "<<p.second<<")\n";}
template <typename A,typename B,typename C>
inline void prt(tuple<A,B,C> p){cout<<"("<<get<0>(p)<<", "<<get<1>(p)<<", "<<get<2>(p)<<")\n";}
inline void prt(bool p){if(p)cout<<"True"<<'\n';else cout<<"False"<<'\n';}
template <typename T> 
inline void prt(vector<T> v){cout<<'{';for(ll i=0;i<v.size();i++){cout<<v[i];if(i<v.size()-1)cout<<", ";}cout<<'}'<<'\n';}
template<typename T> 
inline void prt(vector<vector<T> >& vv){ for(const auto& v : vv){ prt(v); } }
template <typename T> 
inline void prt(deque<T> v){cout<<'{';for(ll i=0;i<v.size();i++){cout<<v[i];if(i<v.size()-1)cout<<", ";}cout<<'}'<<'\n';}
template <typename A,typename B>
inline void prt(map<A,B> v){cout<<'{';ll c=0;for(auto &p: v){cout<<p.first<<":"<<p.second;c++;if(c!=v.size())cout<<", ";}cout<<'}'<<'\n';}
template <typename A,typename B>
inline void prt(unordered_map<A,B> v){cout<<'{';ll c=0;for(auto &p: v){cout<<p.first<<":"<<p.second;c++;if(c!=v.size())cout<<", ";}cout<<'}'<<'\n';}
template <typename T> 
inline void prt(set<T> v){cout<<'{';for(auto i=v.begin();i!=v.end();i++){cout<<*i;if(i!=--v.end())cout<<", ";}cout<<'}'<<'\n';}
template <typename T> 
inline void prt(multiset<T> v){cout<<'{';for(auto i=v.begin();i!=v.end();i++){cout<<*i;if(i!=--v.end())cout<<", ";}cout<<'}'<<'\n';}

/*
方針
Mを大きくするときにその都度計算すれば良さそう

*/


int main(){
	ll n,x,y;
	cin >> n >> x >> y;
	vector<ll>a(n);
	rep(i,n)cin>>a[i];
	vector<ll>xdiff(n+1,0);
	rep(i,n){
		xdiff[i+1]=x-a[i]+xdiff[i];
	}
	vector<ll>ydiff(n+2,0);
	for(int i=n;i>=1;i--){
		ydiff[i]=y-a[i-1]+ydiff[i+1];
	}

	ll s = accumulate(a.begin(),a.end(),0);
	//cout << s << endl;
	ll xMax = -INF;
	ll yMax = -INF;
	ll xMin = 0;
	ll yMin = 0;
	vector<ll>ans(n,s);
	for(int i=2;i<=n-1;i++){
		chmax(xMax,xdiff[i-1]-xMin);
		chmin(xMin,xdiff[i-1]);
		ans[i]+=xMax;
	}
	//debug(ans);

	//debug(ydiff);
	for(int i=n-1;i>=2;i--){
		chmax(yMax,ydiff[i+1]-yMin);
		chmin(yMin,ydiff[i+1]);
		ans[i]+=yMax;
	}

	for(int i=2;i<=n-1;i++){
		cout << ans[i] << endl;
	}

	return 0;
}
0