結果

問題 No.851 テストケース
コンテスト
ユーザー 0w1
提出日時 2019-07-31 20:24:31
言語 C++17
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 2 ms / 3,153 ms
コード長 801 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,007 ms
コンパイル使用メモリ 219,172 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-06-07 15:47:20
合計ジャッジ時間 4,198 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:32:11: warning: ignoring return value of '_FIter std::unique(_FIter, _FIter) [with _FIter = __gnu_cxx::__normal_iterator<long int*, vector<long int> >]', declared with attribute 'nodiscard' [-Wunused-result]
   32 |     unique(sums.begin(), sums.end());
      |     ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/algorithm:63,
                 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:
/home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/stl_algo.h:875:5: note: declared here
  875 |     unique(_ForwardIterator __first, _ForwardIterator __last)
      |     ^~~~~~

ソースコード

diff #
raw source code

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

int main() {
  auto get_ints = []() {
    vector<int64_t> res;
    string buf;
    getline(cin, buf);
    stringstream ss(buf);
    for (string s; ss >> s; ) {
      res.push_back(stoll(s));
    }
    return res;
  };

  int N = get_ints()[0];
  assert(N == 3);

  vector<int64_t> r1 = get_ints();
  if (r1.size() == 3) {
    cout << "\"assert\"" << endl;
  } else {
    r1.push_back(get_ints()[0]);
    r1.push_back(get_ints()[0]);
    vector<int64_t> sums;
    for (int i = 0; i < N; ++i) {
      for (int j = i + 1; j < N; ++j) {
        sums.push_back(r1[i] + r1[j]);
      }
    }
    sort(sums.begin(), sums.end(), [](int64_t x, int64_t y) { return x > y; });
    unique(sums.begin(), sums.end());
    cout << sums[1] << endl;
  }
  
  return 0;
}
0