結果

問題 No.1557 Binary Variable
コンテスト
ユーザー kotatsugame
提出日時 2021-06-25 21:25:28
言語 C++14
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 115 ms / 2,000 ms
コード長 396 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 451 ms
コンパイル使用メモリ 93,848 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2026-03-11 16:59:21
合計ジャッジ時間 4,984 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 34
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    6 | main()
      | ^~~~

ソースコード

diff #
raw source code

#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int N,M;
main()
{
	cin>>N>>M;
	vector<pair<int,int> >A(M);
	for(int i=0;i<M;i++)cin>>A[i].first>>A[i].second;
	sort(A.begin(),A.end(),[](pair<int,int>l,pair<int,int>r){return l.second<r.second;});
	int cnt=0,pre=0;
	for(pair<int,int>p:A)
	{
		if(pre<p.first)
		{
			cnt++;
			pre=p.second;
		}
	}
	cout<<N-cnt<<endl;
}
0