結果

問題 No.647 明太子
ユーザー lunnearlunnear
提出日時 2018-11-14 16:05:45
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,164 bytes
コンパイル時間 375 ms
コンパイル使用メモリ 52,112 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-08-26 01:07:11
合計ジャッジ時間 1,619 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>

struct Mentai
{
    int Price;
    int Hot;
};

int main()
{
    int n, m;
    int *bought;
    Mentai *member;
    Mentai *mentai;
    
    std::cin >> n;
    member = new Mentai[n];
    
    for(int i = 0; i < n; i++)
    {
        std::cin >> member[i].Price >> member[i].Hot;
    }
    
    std::cin >> m;
    mentai = new Mentai[m];
    bought = new int[m];
    
    for(int i = 0; i < m; i++)
    {
        std::cin >> mentai[i].Price >> mentai[i].Hot;
        bought[i] = 0;
    }
    
    
    int max = 0;
    
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < m; j++)
        {
            if((member[i].Price <= mentai[j].Price) && (member[i].Hot >= mentai[j].Hot))
            {
                bought[j]++;
                
                if(bought[j] > max)
                {
                    max = bought[j];
                }
            }
        }
    }
    
    if(max == 0)
    {
        std::cout << "0" << std::endl;
    }
    else
    {
        for(int i = 0; i < m; i++)
        {
            if(bought[i] == max)
                std::cout << (i + 1) << std::endl;
        }
    }
    
    return 0;
}
0