結果

問題 No.1557 Binary Variable
ユーザー tpc011854
提出日時 2021-06-25 23:03:08
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
RE  
実行時間 -
コード長 480 bytes
コンパイル時間 508 ms
コンパイル使用メモリ 45,440 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-25 08:47:35
合計ジャッジ時間 7,848 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 1 WA * 11 RE * 22
権限があれば一括ダウンロードができます

ソースコード

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