結果

問題 No.706 多眼生物の調査
ユーザー @abcde@abcde
提出日時 2019-02-27 00:00:47
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 10 ms / 2,000 ms
コード長 706 bytes
コンパイル時間 1,172 ms
コンパイル使用メモリ 151,172 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-05 09:04:31
合計ジャッジ時間 1,865 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,356 KB
testcase_01 AC 2 ms
4,352 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 5 ms
4,376 KB
testcase_06 AC 10 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
    
    // 1. 入力情報取得.
    int N;
    cin >> N;
    map<int, int> m;
    for(int i = 0; i < N; i++){
        string s;
        cin >> s;
        // 目の数.
        int l = s.size() - 2;
        // 目の数に対応する出現数を, カウントアップ.
        m[l]++;
    }
    
    // 2. 最も頻繁に確認された目の数は?
    int ans = -1, maxFrequency = 0;
    for(auto &p : m){
        int e = p.first, f = p.second;
        if(maxFrequency < f)   maxFrequency = f, ans = e;
        if(maxFrequency <= f && ans < e) ans = e;
    }
    
    // 3. 出力 ~ 終了.
    cout << ans << endl;
    return 0;
    
}
0