結果
| 問題 |
No.686 Uncertain LIS
|
| コンテスト | |
| ユーザー |
夕叢霧香(ゆうむらきりか)
|
| 提出日時 | 2018-05-27 20:45:22 |
| 言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
| 結果 |
TLE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 971 bytes |
| コンパイル時間 | 2,592 ms |
| コンパイル使用メモリ | 105,200 KB |
| 最終ジャッジ日時 | 2025-01-05 10:47:11 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 29 TLE * 7 |
ソースコード
#include<algorithm>
#include<iostream>
#include<vector>
using namespace std;
typedef long long lint;
typedef vector<int>vi;
typedef pair<int,int>pii;
#define rep(i,n)for(int i=0;i<(int)(n);++i)
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int n;
cin>>n;
vi l(n),r(n);
rep(i,n)cin>>l[i]>>r[i];
int ml=0;
vector<int>m(n+1,1e7);
lint cc=0;
bool ab=0;
rep(i,n){
if(cc>=1.1e9){ab=1;break;}
int last=-1;
for(int j=ml+1;j>=1;--j){
int pre=j==1?0:m[j-1];
if(m[j]<=l[i]){last=j;break;}
if(pre+1<=r[i])m[j]=min(m[j],max(l[i],pre+1));
}
cc+=ml+1-last;
if(m[ml+1]<1e7)ml++;
}
if(ab){
ml=0;
rep(i,n+1)m[i]=1e7;
rep(i,n){
int p=0,f=ml+1;
while(f-p>1){
int x=(f+p)/2;
int cur=m[x];
if(max(l[i],cur+1)<=r[i]) p=x;
else f=x;
}
ml=max(ml,p+1);
//UPDATE
m[p+1]=min(m[p+1],max(l[i],p==0?0:m[p]+1));
}
}
cout<<ml<<endl;
}
夕叢霧香(ゆうむらきりか)