結果

問題 No.1990 Candy Boxes
ユーザー kabipoyokabipoyo
提出日時 2022-06-24 23:39:49
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,624 bytes
コンパイル時間 4,393 ms
コンパイル使用メモリ 267,396 KB
実行使用メモリ 7,536 KB
最終ジャッジ日時 2023-08-12 23:12:27
合計ジャッジ時間 9,262 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 WA -
testcase_03 AC 2 ms
4,384 KB
testcase_04 AC 2 ms
4,384 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,384 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,384 KB
testcase_09 AC 1 ms
4,384 KB
testcase_10 AC 2 ms
4,384 KB
testcase_11 AC 2 ms
4,384 KB
testcase_12 AC 44 ms
4,872 KB
testcase_13 AC 48 ms
4,932 KB
testcase_14 AC 21 ms
5,156 KB
testcase_15 AC 25 ms
5,476 KB
testcase_16 AC 25 ms
5,744 KB
testcase_17 AC 28 ms
5,848 KB
testcase_18 AC 28 ms
5,752 KB
testcase_19 AC 43 ms
5,616 KB
testcase_20 AC 49 ms
5,924 KB
testcase_21 AC 47 ms
6,788 KB
testcase_22 AC 42 ms
5,392 KB
testcase_23 AC 55 ms
5,692 KB
testcase_24 AC 53 ms
5,524 KB
testcase_25 AC 76 ms
6,848 KB
testcase_26 AC 30 ms
5,912 KB
testcase_27 AC 29 ms
6,852 KB
testcase_28 AC 31 ms
6,432 KB
testcase_29 AC 31 ms
7,472 KB
testcase_30 AC 25 ms
6,896 KB
testcase_31 AC 32 ms
6,572 KB
testcase_32 AC 18 ms
4,736 KB
testcase_33 AC 25 ms
5,556 KB
testcase_34 AC 34 ms
5,368 KB
testcase_35 AC 49 ms
6,832 KB
testcase_36 AC 47 ms
7,536 KB
testcase_37 AC 34 ms
6,020 KB
testcase_38 AC 29 ms
5,512 KB
testcase_39 AC 32 ms
5,804 KB
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 AC 23 ms
5,876 KB
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 AC 2 ms
4,384 KB
testcase_50 AC 1 ms
4,380 KB
testcase_51 AC 2 ms
4,380 KB
testcase_52 AC 2 ms
4,380 KB
testcase_53 AC 2 ms
4,380 KB
testcase_54 WA -
testcase_55 AC 1 ms
4,380 KB
testcase_56 AC 2 ms
4,380 KB
testcase_57 WA -
testcase_58 WA -
testcase_59 AC 1 ms
4,380 KB
testcase_60 AC 2 ms
4,380 KB
testcase_61 AC 1 ms
4,380 KB
testcase_62 AC 2 ms
4,384 KB
testcase_63 AC 1 ms
4,384 KB
testcase_64 AC 1 ms
4,384 KB
testcase_65 WA -
testcase_66 WA -
testcase_67 AC 47 ms
6,544 KB
testcase_68 AC 21 ms
5,284 KB
testcase_69 AC 51 ms
7,108 KB
testcase_70 WA -
testcase_71 WA -
testcase_72 WA -
testcase_73 AC 55 ms
7,112 KB
testcase_74 WA -
testcase_75 AC 27 ms
5,744 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef int64_t lint;
#define rep(i, n) for(int i=0; i<n; i++)
#define repx(i, l, n) for(int i=l; i<n; i++)
#define all(v) v.begin(), v.end()
#define show(x) cout << #x << ": " << x << endl;
#define list(x) cout << #x << ": " << x << "  ";
#define pb push_back
using vi = vector<lint>;
using vvi = vector<vector<lint>>;
template<class T> inline void vin(vector<T>& v) { rep(i, v.size()) cin >> v.at(i); }
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; }
template<class T> inline void drop(T x) { cout << x << endl; exit(0); }
template<class T> void vout(vector<T> v) { rep(i, v.size()) { cout << v.at(i) << ' '; } cout << endl; }
constexpr lint LINF = LLONG_MAX/2;
using pint = pair<lint, lint>;
using vp = vector<pint>;

int main() {
	lint N;
	cin >> N;
	vi v(N);
	vin(v);
	v.pb(0);
	v.pb(0);

	lint a=0, b=0, c=0, x, y, z;
	vi w(N+2);
	stack<pint> s;
	rep(i, N+2) {
		if (i%2 == 0) {
			w[i] = v[i]-(a+b);
			a += w[i];
			if (a < 0) drop("No");
		} else {
			w[i] = v[i]-(a+b);
			b += w[i];
			if (b < 0) drop("No");
			if (w[i] > 0) s.push({w[i], a%2});
			else {
				x = -w[i];
				while (x > 0) {
					tie(y, z) = s.top();
					s.pop();
					if (z != a%2) drop("No");
					if (x < y) {
						s.push({y-x, z});
						x = 0;
					} else {
						x -= y;
					}
				}
			}
		}
	}
	repx(i, 1, N) w[i] += w[i-1];
	rep(i, N) {
		if (v[i] != w[i]) drop("No");
	}
	std::cout << "Yes" << '\n';
}
0