結果

問題 No.2015 Stair Counter
コンテスト
ユーザー okkuu
提出日時 2022-07-22 21:34:26
言語 C++23
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -fplugin=/usr/lib/yukicoder/noavx512-gcc15.so -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 43 ms / 2,000 ms
+ 595µs
コード長 775 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,294 ms
コンパイル使用メモリ 217,100 KB
実行使用メモリ 9,868 KB
最終ジャッジ日時 2026-10-16 01:31:15
合計ジャッジ時間 4,573 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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