結果

問題 No.647 明太子
ユーザー kichirb3kichirb3
提出日時 2018-03-02 08:35:45
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 39 ms / 4,500 ms
コード長 1,325 bytes
コンパイル時間 790 ms
コンパイル使用メモリ 80,228 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-09 09:38:05
合計ジャッジ時間 1,978 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 3 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 3 ms
4,376 KB
testcase_13 AC 4 ms
4,384 KB
testcase_14 AC 30 ms
4,376 KB
testcase_15 AC 6 ms
4,380 KB
testcase_16 AC 3 ms
4,376 KB
testcase_17 AC 37 ms
4,376 KB
testcase_18 AC 39 ms
4,376 KB
testcase_19 AC 7 ms
4,376 KB
testcase_20 AC 7 ms
4,376 KB
testcase_21 AC 4 ms
4,376 KB
testcase_22 AC 22 ms
4,376 KB
testcase_23 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// No.647 明太子
// https://yukicoder.me/problems/no/647
//
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
using namespace std;

int main() {
    cin.tie(nullptr);

    // メンバーの購入条件を設定
    int N;
    cin >> N;
    vector<pair<int, int>> criteria;
    for (auto i = 0; i < N; ++i) {
        int A, B;
        cin >> A >> B;
        criteria.emplace_back(make_pair(A, B));
    }

    // 明太子の価格と辛さを確認
    int M;
    cin >> M;
    vector<pair<int, int>> mentaiko;
    for (auto i = 0; i < M; ++i) {
        int X, Y;
        cin >> X >> Y;
        mentaiko.emplace_back(make_pair(X, Y));
    }

    // メンバごとに条件にマッチする明太子を購入
    vector<int> votes(M+1, 0);
    for (auto i = 0; i < N; ++i) {
        for (auto j = 0; j < M; ++j) {
            if (mentaiko[j].first <= criteria[i].first && mentaiko[j].second >= criteria[i].second)
                ++votes[j];
        }
    }

    int votes_max = *max_element(votes.begin(), votes.end()); // 奇跡の明太子の購入者数
    if (votes_max == 0) {
        cout << 0 << endl;
    } else {
        for (auto i = 0; i < M; ++i) {
            if (votes[i] == votes_max)
                cout << i + 1 << endl; // 0起算なので+1して出力
        }
    }
}
0