結果
| 問題 | 
                            No.1290 Addition and Subtraction Operation
                             | 
                    
| コンテスト | |
| ユーザー | 
                             tails
                         | 
                    
| 提出日時 | 2020-11-13 23:07:49 | 
| 言語 | cLay  (20241019-1)  | 
                    
| 結果 | 
                             
                                TLE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 629 bytes | 
| コンパイル時間 | 2,342 ms | 
| コンパイル使用メモリ | 181,412 KB | 
| 実行使用メモリ | 10,752 KB | 
| 最終ジャッジ日時 | 2024-07-05 14:45:31 | 
| 合計ジャッジ時間 | 6,126 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 1 TLE * 1 -- * 83 | 
ソースコード
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");
}
            
            
            
        
            
tails