結果
問題 | No.1375 Divide and Update |
ユーザー | Rubikun |
提出日時 | 2023-08-13 19:15:46 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 51 ms / 2,000 ms |
コード長 | 1,333 bytes |
コンパイル時間 | 2,848 ms |
コンパイル使用メモリ | 202,820 KB |
実行使用メモリ | 9,472 KB |
最終ジャッジ日時 | 2023-08-13 19:15:54 |
合計ジャッジ時間 | 7,331 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,380 KB |
testcase_01 | AC | 2 ms
4,376 KB |
testcase_02 | AC | 2 ms
4,380 KB |
testcase_03 | AC | 1 ms
4,380 KB |
testcase_04 | AC | 2 ms
4,380 KB |
testcase_05 | AC | 2 ms
4,376 KB |
testcase_06 | AC | 2 ms
4,380 KB |
testcase_07 | AC | 1 ms
4,380 KB |
testcase_08 | AC | 1 ms
4,376 KB |
testcase_09 | AC | 1 ms
4,380 KB |
testcase_10 | AC | 44 ms
8,700 KB |
testcase_11 | AC | 40 ms
8,148 KB |
testcase_12 | AC | 22 ms
5,796 KB |
testcase_13 | AC | 19 ms
5,528 KB |
testcase_14 | AC | 50 ms
9,352 KB |
testcase_15 | AC | 50 ms
9,400 KB |
testcase_16 | AC | 49 ms
9,420 KB |
testcase_17 | AC | 48 ms
9,472 KB |
testcase_18 | AC | 51 ms
9,324 KB |
testcase_19 | AC | 50 ms
9,404 KB |
testcase_20 | AC | 38 ms
9,376 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; } template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; } #define all(x) (x).begin(),(x).end() #define fi first #define se second #define mp make_pair #define si(x) int(x.size()) const int mod=998244353,MAX=300005,INF=1<<30; int main(){ std::ifstream in("text.txt"); std::cin.rdbuf(in.rdbuf()); cin.tie(0); ios::sync_with_stdio(false); ll N,X,Y;cin>>N>>X>>Y; vector<ll> ans1(N),ans2(N); ll sum=0; vector<ll> A(N); for(int i=0;i<N;i++){ cin>>A[i]; sum+=A[i]; } { vector<ll> S(N+1); for(int i=0;i<N;i++) S[i+1]=S[i]+X-A[i]; ll ma=-INF,mi=INF; for(int i=0;i<N;i++){ chmax(ma,S[i]-mi); ans1[i]=ma; chmin(mi,S[i]); } } { reverse(all(A)); vector<ll> S(N+1); for(int i=0;i<N;i++) S[i+1]=S[i]+Y-A[i]; ll ma=-INF,mi=INF; for(int i=0;i<N;i++){ chmax(ma,S[i]-mi); ans2[i]=ma; chmin(mi,S[i]); } reverse(all(ans2)); } for(int i=1;i<N-1;i++) cout<<sum+ans1[i]+ans2[i]<<"\n"; }