結果

問題 No.647 明太子
ユーザー oooooba
提出日時 2021-03-21 20:45:58
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 46 ms / 4,500 ms
コード長 1,387 bytes
コンパイル時間 1,199 ms
コンパイル使用メモリ 121,376 KB
最終ジャッジ日時 2025-01-19 20:55:12
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <optional>
#include <queue>
#include <set>
#include <sstream>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

int main() {
    int32_t n;
    cin >> n;
    vector<pair<int32_t, int32_t>> abs(n);
    for (auto i = 0; i < n; ++i) {
        int32_t a, b;
        cin >> a >> b;
        abs[i] = {a, b};
    }
    int32_t m;
    cin >> m;
    vector<pair<int32_t, int32_t>> xys(m);
    for (auto i = 0; i < m; ++i) {
        int32_t x, y;
        cin >> x >> y;
        xys[i] = {x, y};
    }
    vector<int32_t> hist(m);
    for (auto i = 0; i < n; ++i) {
        for (auto j = 0; j < m; ++j) {
            if (abs[i].first >= xys[j].first &&
                abs[i].second <= xys[j].second) {
                ++hist[j];
            }
        }
    }
    vector<pair<int32_t, int32_t>> vs(m);
    for (auto i = 0; i < m; ++i) {
        vs[i] = {-hist[i], i + 1};
    }
    sort(vs.begin(), vs.end());
    if (vs[0].first == 0) {
        cout << 0 << endl;
    } else {
        cout << vs[0].second << endl;
        for (auto i = 1; i < m; ++i) {
            if (vs[i].first != vs[i - 1].first)
                break;
            cout << vs[i].second << endl;
        }
    }
    return 0;
}
0