結果

問題 No.2796 Small Matryoshka
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2024-06-28 22:44:00
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 134 ms / 2,000 ms
コード長 1,197 bytes
コンパイル時間 2,257 ms
コンパイル使用メモリ 188,268 KB
実行使用メモリ 14,208 KB
最終ジャッジ日時 2024-06-28 22:44:16
合計ジャッジ時間 4,258 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 12 ms
5,376 KB
testcase_06 AC 67 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 53 ms
5,376 KB
testcase_09 AC 132 ms
14,208 KB
testcase_10 AC 133 ms
14,208 KB
testcase_11 AC 134 ms
14,208 KB
testcase_12 AC 40 ms
6,144 KB
testcase_13 AC 7 ms
5,376 KB
testcase_14 AC 35 ms
5,760 KB
testcase_15 AC 11 ms
5,376 KB
testcase_16 AC 18 ms
5,376 KB
testcase_17 AC 74 ms
7,040 KB
testcase_18 AC 86 ms
7,552 KB
testcase_19 AC 25 ms
5,376 KB
testcase_20 AC 34 ms
5,376 KB
testcase_21 AC 74 ms
7,040 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <deque>
#include <forward_list>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <optional>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    cin >> n;
    vector<pair<int,int>> R(n);
    for (auto &r : R) cin >> r.first >> r.second;

    sort(R.begin(),R.end(),[](auto a, auto b){
            if (a.second == b.second) return a.first < b.first;
            return a.second < b.second;
            });

    multiset<int> S;
    for (auto [l,r] : R){
        auto it = S.upper_bound(l);
        if (it != S.begin()){
            S.erase(--it);
        }
        S.insert(r);

    }
    cout << S.size()-1 << endl;

    return 0;

}
0