結果
問題 |
No.2667 Constrained Permutation
|
ユーザー |
![]() |
提出日時 | 2024-03-08 23:00:31 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,090 bytes |
コンパイル時間 | 2,014 ms |
コンパイル使用メモリ | 205,452 KB |
最終ジャッジ日時 | 2025-02-20 02:56:50 |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 16 WA * 30 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define int long long signed main(){ int N; cin>>N; vector<pair<int,int>> S(N); for(int i=0;i<N;i++) cin>>S[i].first>>S[i].second; sort(S.begin(),S.end()); int ind = 0; priority_queue<int,vector<int>,greater<int>> pq; for(int i=S[0].first;i<S[0].first+N;i++){ while(ind != N && S[ind].first <= i){ pq.push(S[ind].second); ind++; } if(pq.empty() || pq.top() < i){ cout<<0<<endl; return 0; } pq.pop(); } int l = 0; for(int z=30;z>=0;z--){ while(pq.size()) pq.pop(); ind = 0; l += (1ll<<z); bool p = true; for(int i=S[0].first+l;i<S[0].first+N+l;i++){ while(ind != N && S[ind].first <= i){ pq.push(S[ind].second); ind++; } if(pq.empty() || pq.top() < i){ p = false; break; } pq.pop(); } if(!p) l -= (1<<z); } cout<<1+l<<endl; }