結果

問題 No.2015 Stair Counter
ユーザー okkuukenkenokkuukenken
提出日時 2022-07-22 21:34:26
言語 C++23(draft)
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 59 ms / 2,000 ms
コード長 775 bytes
コンパイル時間 1,266 ms
コンパイル使用メモリ 128,928 KB
実行使用メモリ 5,764 KB
最終ジャッジ日時 2023-09-17 09:04:38
合計ジャッジ時間 3,524 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 36 ms
4,376 KB
testcase_02 AC 40 ms
4,376 KB
testcase_03 AC 42 ms
4,380 KB
testcase_04 AC 34 ms
4,380 KB
testcase_05 AC 31 ms
4,376 KB
testcase_06 AC 46 ms
4,380 KB
testcase_07 AC 46 ms
4,380 KB
testcase_08 AC 46 ms
4,376 KB
testcase_09 AC 24 ms
4,376 KB
testcase_10 AC 25 ms
4,376 KB
testcase_11 AC 28 ms
4,380 KB
testcase_12 AC 24 ms
4,380 KB
testcase_13 AC 25 ms
4,380 KB
testcase_14 AC 29 ms
4,380 KB
testcase_15 AC 34 ms
4,756 KB
testcase_16 AC 56 ms
5,344 KB
testcase_17 AC 24 ms
5,280 KB
testcase_18 AC 48 ms
5,056 KB
testcase_19 AC 59 ms
5,640 KB
testcase_20 AC 30 ms
5,764 KB
testcase_21 AC 33 ms
4,376 KB
testcase_22 AC 39 ms
4,380 KB
testcase_23 AC 44 ms
4,376 KB
testcase_24 AC 35 ms
4,380 KB
testcase_25 AC 35 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<iomanip>
#include<numeric>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<random>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
int tmp[2][200000];
int main(){
	static int t,n,a[200001];
	cin>>t;
	while(cin>>n>>a[0]){
		for(int i=1;i<=n;i++)
			cin>>a[i];
		if(a[n]!=a[0]){
			cout<<"No"<<endl;
			continue;
		}
		tmp[0][0]=a[1];
		bool ok=1;
		for(int i=0;i<n-1;i++){
			tmp[1][i]=a[i]-tmp[0][i];
			if(tmp[1][i]<0)
				ok=0;
			tmp[0][i+1]=a[i+2]-tmp[1][i];
			if(tmp[0][i+1]<0)
				ok=0;
		}
		if(tmp[0][n-1]!=a[n-1]){
			cout<<"No"<<endl;
			continue;
		}
		cout<<(ok?"Yes":"No")<<endl;
	}
}
0