結果

問題 No.706 多眼生物の調査
ユーザー gotutiyangotutiyan
提出日時 2018-07-07 14:58:01
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 10 ms / 2,000 ms
コード長 566 bytes
コンパイル時間 627 ms
コンパイル使用メモリ 79,436 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-17 18:52:16
合計ジャッジ時間 1,221 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 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 5 ms
4,376 KB
testcase_06 AC 10 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:30:11: 警告: ‘ans’ may be used uninitialized [-Wmaybe-uninitialized]
   30 |     cout<<ans<<endl;
      |           ^~~
main.cpp:23:19: 備考: ‘ans’ はここで定義されています
   23 |     int maxnum=-1,ans;
      |                   ^~~

ソースコード

diff #

#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <queue>
#include <stack>
#include <cmath>
#include <numeric>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int> v(1010,0);
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        v[s.size()-2]++;
    }
    int maxnum=-1,ans;
    for(int i=0;i<1010;i++){
        if(maxnum<=v[i]){
            maxnum=v[i];
            ans=i;
        }
    }
    cout<<ans<<endl;
}
0