結果

問題 No.79 過小評価ダメ・ゼッタイ
コンテスト
ユーザー kuisiba
提出日時 2016-03-30 17:34:17
言語 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  
実行時間 13 ms / 5,000 ms
コード長 647 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 681 ms
コンパイル使用メモリ 85,364 KB
実行使用メモリ 7,720 KB
最終ジャッジ日時 2026-03-12 23:48:38
合計ジャッジ時間 1,614 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:22:13: warning: ignoring return value of '_IIter std::find(_IIter, _IIter, const _Tp&) [with _IIter = __gnu_cxx::__normal_iterator<int*, vector<int> >; _Tp = int]', declared with attribute 'nodiscard' [-Wunused-result]
   22 |         find(itr, vec.end(), a);
      |         ~~~~^~~~~~~~~~~~~~~~~~~
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/algorithm:63,
                 from main.cpp:3:
/home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/stl_algo.h:3854:5: note: declared here
 3854 |     find(_InputIterator __first, _InputIterator __last, const _Tp& __val)
      |     ^~~~

ソースコード

diff #
raw source code

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int n;
    cin >>n;
    int temp;
    vector<int> vec;
    for (int i = 0; i < n; ++i) {
        cin >> temp;
        vec.push_back(temp);
    }
    sort(vec.begin(),vec.end());

    auto itr = vec.begin();
    int a = 1;
    vector<int> b(6, 0);
    while (1) {
        find(itr, vec.end(), a);
        if (*itr != a) a++;
        else {
            b.at(a - 1)++;
            itr++;
        }
        if (itr == vec.end()) break;
    }
    auto max = max_element(b.rbegin(), b.rend());
    cout << distance(max, b.rend()) <<endl;
    return 0;
}
0