結果

問題 No.2796 Small Matryoshka
ユーザー 沙耶花沙耶花
提出日時 2024-06-28 21:29:41
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 314 ms / 2,000 ms
コード長 896 bytes
コンパイル時間 4,028 ms
コンパイル使用メモリ 270,208 KB
実行使用メモリ 27,488 KB
最終ジャッジ日時 2024-06-28 21:30:55
合計ジャッジ時間 7,247 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 1 ms
6,944 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 36 ms
6,940 KB
testcase_06 AC 227 ms
19,676 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 164 ms
12,824 KB
testcase_09 AC 314 ms
27,488 KB
testcase_10 AC 270 ms
23,116 KB
testcase_11 AC 281 ms
25,788 KB
testcase_12 AC 68 ms
7,460 KB
testcase_13 AC 9 ms
6,940 KB
testcase_14 AC 58 ms
6,948 KB
testcase_15 AC 16 ms
6,940 KB
testcase_16 AC 28 ms
6,940 KB
testcase_17 AC 197 ms
17,388 KB
testcase_18 AC 217 ms
19,424 KB
testcase_19 AC 61 ms
8,352 KB
testcase_20 AC 86 ms
10,152 KB
testcase_21 AC 215 ms
17,372 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 1000000000000000001

int main(){
	
	int n;
	cin>>n;
	
	vector<int> a(n),b(n);
	vector<int> t;
	rep(i,n){
		cin>>a[i]>>b[i];
		t.push_back(a[i]);
		t.push_back(b[i]);
	}
	sort(t.begin(),t.end());
	t.erase(unique(t.begin(),t.end()),t.end());
	vector<vector<int>> E(t.size());
	rep(i,n){
		a[i]=lower_bound(t.begin(),t.end(),a[i])-t.begin();
		b[i]=lower_bound(t.begin(),t.end(),b[i])-t.begin();
		E[b[i]].push_back(a[i]);
	}
	
	multiset<int> S;
	rep(i,t.size()){
		rep(j,E[i].size()){
			auto it = S.upper_bound(E[i][j]);
			if(it==S.begin()){
				S.insert(i);
			}
			else{
				it--;
				S.erase(it);
				S.insert(i);
			}
		}
	}
	cout<<S.size()-1<<endl;
	return 0;
}
0