結果

問題 No.647 明太子
ユーザー lunnear
提出日時 2018-11-14 16:05:45
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 1,164 bytes
コンパイル時間 466 ms
コンパイル使用メモリ 54,908 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-24 13:43:20
合計ジャッジ時間 1,591 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 4
other AC * 4 WA * 16
権限があれば一括ダウンロードができます

ソースコード

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