結果

問題 No.2796 Small Matryoshka
ユーザー srjywrdnprkt
提出日時 2024-07-02 14:04:40
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 85 ms / 2,000 ms
コード長 645 bytes
コンパイル時間 2,092 ms
コンパイル使用メモリ 201,152 KB
最終ジャッジ日時 2025-02-22 01:50:06
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

    //全てのxについて、L_i <= x <= R_iを満たすiの数の最大値だけ操作しなければならない。
    int N, mx=0, s=0, a, b;
    cin >> N;
    vector<pair<int, int>> v;
    for (int i=0; i<N; i++){
        cin >> a >> b; b--;
        v.push_back({a, -1});
        v.push_back({b, 1});
    }

    sort(v.begin(), v.end());
    for (auto [a, b] : v){
        if (b == -1) s++;
        else if (b == 1) s--;
        mx = max(mx, s);
    }
    cout << mx-1 << endl;

    return 0;
}
0