結果

問題 No.1290 Addition and Subtraction Operation
ユーザー tails
提出日時 2020-11-13 23:01:18
言語 cLay
(20241019-1)
結果
RE  
実行時間 -
コード長 630 bytes
コンパイル時間 3,145 ms
コンパイル使用メモリ 182,060 KB
実行使用メモリ 9,248 KB
最終ジャッジ日時 2024-07-05 14:46:24
合計ジャッジ時間 10,498 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 48 WA * 1 RE * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

priority_queue<pair<ll,ll>> q;

ll bs[1d5];
ll ad,as[1d5+1];

{
	int @n,@m;
	rd(bs(n));
	rep(m){
		ll @l,@r;
		q.push({-(l-1),-(r)});
	}
	rep(i,0,n,2)bs[i]=-bs[i];
	int x=0;
	while(!q.empty()){
		pair<ll,ll> p=q.top();
		q.pop();
		ll l=-p.first;
		ll r=-p.second;
		while(x<l){
			ad+=as[x];
			if(bs[x]!=ad){
				wt("NO");
				exit(0);
			}
			++x;
		}
		while(!q.empty()&&-q.top().first==l){
			pair<ll,ll> p2=q.top();
			q.pop();
			q.push({-r,-p2.second});
		}
		ad+=as[x];
		as[r]-=bs[x]-ad;
		ad=bs[x];
		++x;
	}
	{
		while(x<n){
			ad+=as[x];
			if(bs[x]!=ad){
				wt("NO");
				exit(0);
			}
			++x;
		}
	}
	wt("YES");
}
0