結果

問題 No.2796 Small Matryoshka
ユーザー lingfunny
提出日時 2024-06-28 21:39:36
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 570 bytes
コンパイル時間 2,929 ms
コンパイル使用メモリ 247,632 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-28 21:39:46
合計ジャッジ時間 4,014 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 8 WA * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using LL = long long;

const int mxn = 2e5 + 10;

int n;

struct node {
	int R, r;
} a[mxn];

int main() {
	ios::sync_with_stdio(false);
	cin >> n;
	for (int i = 1; i <= n; ++i)
		cin >> a[i].r >> a[i].R;
	sort(a + 1, a + n + 1, [&](const node &lhs, const node &rhs) {
		return lhs.R == rhs.R ? lhs.r > rhs.r : lhs.R > rhs.R;
	});
	int lstr = a[1].r, ans = 0;
	for (int i = 2; i <= n; ++i) {
		if (a[i].R > lstr) {
			++ans;
			lstr = max(lstr, a[i].r);
		} else {
			lstr = a[i].r;
		}
	}
	cout << ans << "\n";
	return 0;
}
0