結果

問題 No.2796 Small Matryoshka
ユーザー kentikenti
提出日時 2024-06-28 22:25:43
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 198 ms / 2,000 ms
コード長 593 bytes
コンパイル時間 1,758 ms
コンパイル使用メモリ 99,640 KB
実行使用メモリ 6,784 KB
最終ジャッジ日時 2024-06-28 22:25:50
合計ジャッジ時間 3,476 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
using namespace std;
typedef pair<int, int> P;

const int MAX_N = 200000;
int N, r, R;
P mat[MAX_N * 2];

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> r >> R;
        mat[i * 2] = make_pair(r, 1);
        mat[i * 2 + 1] = make_pair(R, -1);
    }
    sort(mat, mat + 2 * N);
    int num = 0, rad = 0, ans = 0;
    for (int i = 0; i < 2 * N; i++) {
        if (rad != mat[i].first)
            ans = max(ans, num);
        num += mat[i].second;
        rad = mat[i].first;
    }
    cout << ans - 1 << endl;
    return 0;
}
0