結果

問題 No.2015 Stair Counter
ユーザー 沙耶花沙耶花
提出日時 2022-07-22 21:26:11
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 63 ms / 2,000 ms
コード長 631 bytes
コンパイル時間 4,629 ms
コンパイル使用メモリ 261,852 KB
実行使用メモリ 6,548 KB
最終ジャッジ日時 2023-09-17 08:47:02
合計ジャッジ時間 7,022 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 38 ms
4,380 KB
testcase_02 AC 42 ms
4,380 KB
testcase_03 AC 43 ms
4,380 KB
testcase_04 AC 35 ms
4,376 KB
testcase_05 AC 32 ms
4,376 KB
testcase_06 AC 49 ms
4,376 KB
testcase_07 AC 48 ms
4,376 KB
testcase_08 AC 49 ms
4,376 KB
testcase_09 AC 25 ms
4,376 KB
testcase_10 AC 25 ms
4,376 KB
testcase_11 AC 29 ms
4,380 KB
testcase_12 AC 25 ms
4,376 KB
testcase_13 AC 26 ms
4,380 KB
testcase_14 AC 31 ms
4,376 KB
testcase_15 AC 37 ms
4,916 KB
testcase_16 AC 60 ms
5,940 KB
testcase_17 AC 27 ms
5,468 KB
testcase_18 AC 51 ms
5,508 KB
testcase_19 AC 63 ms
6,292 KB
testcase_20 AC 32 ms
6,548 KB
testcase_21 AC 35 ms
4,380 KB
testcase_22 AC 40 ms
4,376 KB
testcase_23 AC 46 ms
4,376 KB
testcase_24 AC 36 ms
4,376 KB
testcase_25 AC 36 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000000



int main(){
	
	int _t;
	cin>>_t;
	
	rep(_,_t){
		long long N,M;
		cin>>N>>M;
		
		vector<long long> a(N);
		rep(i,N)cin>>a[i];
		a.insert(a.begin(),M);
		a.push_back(0LL);
		vector<long long> b(a.size(),0);
		b[0] = M;
		rep(i,b.size()-2){
			long long x = max(0LL,a[i+1]-b[i+1]);
			x = min(x,b[i]);
			b[i+1] += x;
			b[i+2] += b[i]-x;
		}
		if(a==b)cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
    return 0;
}
0