結果

問題 No.706 多眼生物の調査
コンテスト
ユーザー shikaku
提出日時 2018-06-29 22:36:47
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 7 ms / 2,000 ms
コード長 701 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,063 ms
コンパイル使用メモリ 178,192 KB
実行使用メモリ 7,720 KB
最終ジャッジ日時 2026-03-21 14:02:45
合計ジャッジ時間 1,372 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 5
権限があれば一括ダウンロードができます
コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/algorithm:62,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/x86_64-pc-linux-gnu/bits/stdc++.h:53,
                 from main.cpp:1:
In function 'const _Tp& std::max(const _Tp&, const _Tp&) [with _Tp = int]',
    inlined from 'int main()' at main.cpp:42:26:
/home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/stl_algobase.h:263:7: warning: 'k' may be used uninitialized [-Wmaybe-uninitialized]
  263 |       if (__a < __b)
      |       ^~
main.cpp: In function 'int main()':
main.cpp:9:15: note: 'k' was declared here
    9 |     int n, i, k;
      |               ^

ソースコード

diff #
raw source code

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


int main(){
                                                                     

    int n, i, k;

    string t;

    int m = 0;


    cin >> n;

    vector<int> s(1001);


    for( i = 0 ; i < n ; i = i + 1 ){

         cin >> t;

         s.at( t.size() - 2 ) += 1;

         }


    for( i = 0 ; i < 1001 ; i = i + 1 ){

         if( m < s.at(i) ){

             m = s.at(i);

             k = i;

             }

         else if( m == s.at(i) ){

                  k = max( k, i );

                  }

         }


    cout << k << endl;


    return 0;

    }
0