結果

問題 No.686 Uncertain LIS
ユーザー chocorusk
提出日時 2018-12-18 12:30:31
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
TLE  
実行時間 -
コード長 951 bytes
コンパイル時間 763 ms
コンパイル使用メモリ 94,444 KB
実行使用メモリ 13,756 KB
最終ジャッジ日時 2024-09-25 07:43:17
合計ジャッジ時間 4,782 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 9 TLE * 1 -- * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const int INF=1e9;
int bit[100002]; int n0;
int mx[100002];
int max(int i){
	int s=0;
	while(i>0){
		s=max(s, bit[i]);
		i-=(i&(-i));
	}
	return s;
}
void update(int i, int x){
	if(mx[i]>=x) return;
	mx[i]=x;
	while(i<=n0){
		bit[i]=max(bit[i], x);
		i+=(i&(-i));
	}
}
int main()
{
	n0=1e5;
	int n; cin>>n;
	int l[100001], r[100001];
	cin>>l[0]>>r[0];
	for(int j=l[0]; j<=r[0]; j++){
		update(j, 1);
	}
	for(int i=1; i<n; i++){
		cin>>l[i]>>r[i];
		for(int j=r[i]; j>=l[i]; j--){
			int m=max(j-1);
			update(j, m+1);
		}
	}
	cout<<max(n0)<<endl;
	return 0;
}
0