結果

問題 No.1557 Binary Variable
ユーザー tpc011854tpc011854
提出日時 2021-06-25 23:03:08
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 480 bytes
コンパイル時間 592 ms
コンパイル使用メモリ 44,752 KB
実行使用メモリ 4,640 KB
最終ジャッジ日時 2023-09-07 14:55:12
合計ジャッジ時間 8,560 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 AC 1 ms
4,380 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 RE -
testcase_15 WA -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 AC 1 ms
4,380 KB
testcase_35 AC 2 ms
4,380 KB
testcase_36 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <algorithm>

struct Element {
	int l,r;
};
Element a[200005];

int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i = 1; i <= m; i++){
		scanf("%d%d",&a[i].l,&a[i].r);
	}
	std::sort(a+1,a+1+m,[](Element& u, Element& v){
		return u.r < v.r;
	});
	int ans = 0;
	int p = 1;
	int right = 0;
	while(p<=n){
		int np = p;
		while(np<=n && a[np].l<=right) np++;
		if(np>n) break;
		ans++;
		right = a[np].r;
		p = np+1;
	}
	printf("%d\n",n-ans);
	return 0;
}
0