結果
| 問題 | No.706 多眼生物の調査 | 
| コンテスト | |
| ユーザー |  gotutiyan | 
| 提出日時 | 2018-07-07 14:58:01 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 11 ms / 2,000 ms | 
| コード長 | 566 bytes | 
| コンパイル時間 | 717 ms | 
| コンパイル使用メモリ | 80,084 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-07-04 13:17:04 | 
| 合計ジャッジ時間 | 1,145 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 5 | 
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:30:11: warning: 'ans' may be used uninitialized [-Wmaybe-uninitialized]
   30 |     cout<<ans<<endl;
      |           ^~~
main.cpp:23:19: note: 'ans' was declared here
   23 |     int maxnum=-1,ans;
      |                   ^~~
            
            ソースコード
#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;
}
            
            
            
        