結果
問題 |
No.1290 Addition and Subtraction Operation
|
ユーザー |
![]() |
提出日時 | 2020-11-13 22:59:55 |
言語 | cLay (20241019-1) |
結果 |
WA
|
実行時間 | - |
コード長 | 649 bytes |
コンパイル時間 | 2,648 ms |
コンパイル使用メモリ | 181,240 KB |
実行使用メモリ | 8,036 KB |
最終ジャッジ日時 | 2024-07-05 14:45:00 |
合計ジャッジ時間 | 7,065 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 76 WA * 9 |
ソースコード
priority_queue<pair<ll,ll>> q; ll bs[1d5]; ll ad,as[1d5+1]; int lc[1d5],rc[1d5]; { 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"); }