結果

問題 No.686 Uncertain LIS
ユーザー PulmnPulmn
提出日時 2017-09-12 22:31:07
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 295 ms / 2,000 ms
コード長 756 bytes
コンパイル時間 663 ms
コンパイル使用メモリ 71,416 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-08 00:07:16
合計ジャッジ時間 5,803 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 3 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 3 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 142 ms
5,376 KB
testcase_10 AC 132 ms
5,376 KB
testcase_11 AC 94 ms
5,376 KB
testcase_12 AC 7 ms
5,376 KB
testcase_13 AC 51 ms
5,376 KB
testcase_14 AC 29 ms
5,376 KB
testcase_15 AC 20 ms
5,376 KB
testcase_16 AC 46 ms
5,376 KB
testcase_17 AC 154 ms
5,376 KB
testcase_18 AC 158 ms
5,376 KB
testcase_19 AC 160 ms
5,376 KB
testcase_20 AC 64 ms
5,376 KB
testcase_21 AC 65 ms
5,376 KB
testcase_22 AC 42 ms
5,376 KB
testcase_23 AC 43 ms
5,376 KB
testcase_24 AC 108 ms
5,376 KB
testcase_25 AC 105 ms
5,376 KB
testcase_26 AC 285 ms
5,376 KB
testcase_27 AC 117 ms
5,376 KB
testcase_28 AC 117 ms
5,376 KB
testcase_29 AC 112 ms
5,376 KB
testcase_30 AC 117 ms
5,376 KB
testcase_31 AC 3 ms
5,376 KB
testcase_32 AC 123 ms
5,376 KB
testcase_33 AC 295 ms
5,376 KB
testcase_34 AC 158 ms
5,376 KB
testcase_35 AC 166 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <queue>
using namespace std;

const int M=320;

int n,res,a[M]={0};
deque<int> q[M];

int main(){
	cin>>n;
	for(int i=0;i<M;i++) for(int j=0;j<M;j++) q[i].push_back(0);
	for(int i=0;i<n;i++){
		int l,r;
		cin>>l>>r;
		int li=l/M,ri=r/M,b=1;
		for(int j=r%M;j<M;j++) if(q[ri][j]){
			q[ri][j]=b=0;
			a[ri]--;
			break;
		}
		if(b&&ri!=M-1){
			int I=ri+1;
			while(I<M&&!a[I]) I++;
			if(I<M){
				for(int j=0;j<M;j++) if(q[I][j]){
					q[I][j]=b=0;
					a[I]--;
					break;
				}
			}
		}
		res+=b;
		q[ri].erase(q[ri].begin()+r%M);
		for(int j=li;j<ri;j++){
			int t=q[j].back();
			a[j]-=t;
			a[j+1]+=t;
			q[j].pop_back();
			q[j+1].push_front(t);
		}
		q[li].insert(q[li].begin()+l%M,1);
		a[li]++;
	}
	cout<<res<<endl;
}
0