結果

問題 No.79 過小評価ダメ・ゼッタイ
ユーザー face4
提出日時 2018-04-20 20:18:40
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 17 ms / 5,000 ms
コード長 367 bytes
コンパイル時間 519 ms
コンパイル使用メモリ 65,216 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-27 05:16:32
合計ジャッジ時間 1,719 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:20:13: warning: 'maxIndex' may be used uninitialized [-Wmaybe-uninitialized]
   20 |     cout << maxIndex << endl;
      |             ^~~~~~~~
main.cpp:12:24: note: 'maxIndex' was declared here
   12 |     int maxValue = -1, maxIndex;
      |                        ^~~~~~~~

ソースコード

diff #

#include<iostream>
using namespace std;

int main(){
    int n, t, V[7] = {};
    cin >> n;
    while(n-- > 0){
        cin >> t;
        V[t]++;
    }

    int maxValue = -1, maxIndex;
    for(int i = 1; i <= 6; i++){
        if(maxValue <= V[i]){
            maxIndex = i;
            maxValue = V[i];
        }
    }

    cout << maxIndex << endl;
    return 0;
}
0