結果
問題 | No.1557 Binary Variable |
ユーザー | NullKara |
提出日時 | 2021-06-25 21:43:19 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 179 ms / 2,000 ms |
コード長 | 553 bytes |
コンパイル時間 | 758 ms |
コンパイル使用メモリ | 76,360 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-25 08:20:09 |
合計ジャッジ時間 | 7,314 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 34 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> using namespace std; int N, M; typedef pair<int,int> pint; vector<pint> A; bool cmp(pint a, pint b) { return a.second < b.second; } int main() { cin >> N >> M; A.resize(M); for (int i = 0; i < M; ++i) cin >> A[i].first >> A[i].second; sort(A.begin(), A.end(), cmp); int res = 0; int endtime = 0; for (int i = 0; i < M; ++i) { if (A[i].first-1 >= endtime) { endtime = A[i].second; ++res; } } cout << N-res << endl; }