結果
問題 | No.1374 Absolute Game |
ユーザー | RheoTommy |
提出日時 | 2021-02-05 22:03:00 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,614 bytes |
コンパイル時間 | 2,588 ms |
コンパイル使用メモリ | 209,632 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-02 12:31:35 |
合計ジャッジ時間 | 4,166 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 2 ms
6,940 KB |
testcase_02 | AC | 2 ms
6,944 KB |
testcase_03 | AC | 2 ms
6,944 KB |
testcase_04 | AC | 2 ms
6,940 KB |
testcase_05 | AC | 2 ms
6,940 KB |
testcase_06 | AC | 2 ms
6,940 KB |
testcase_07 | AC | 2 ms
6,940 KB |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
コンパイルメッセージ
main.cpp: In function 'int main()': main.cpp:57:24: warning: ignoring return value of 'std::deque<_Tp, _Alloc>::reference std::deque<_Tp, _Alloc>::back() [with _Tp = long long int; _Alloc = std::allocator<long long int>; reference = long long int&]', declared with attribute 'nodiscard' [-Wunused-result] 57 | ci.back(); | ~~~~~~~^~ In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/deque:64, from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/x86_64-pc-linux-gnu/bits/stdc++.h:68, from main.cpp:1: /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/stl_deque.h:1468:7: note: declared here 1468 | back() _GLIBCXX_NOEXCEPT | ^~~~
ソースコード
#include<bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int) n; i++) using ll = long long; using namespace std; const long long INF = 1ll << 60; void chmax(ll &x, ll y) { x = max(x, y); } int main() { ll n; cin >> n; deque<ll> c; rep(i, n) { ll ci; cin >> ci; c.push_back(ci); }; ll ans = -INF; // big big { deque<ll> ci = c; vector<ll> score(2, 0); rep(i, n) { score[i % 2] += ci.front(); ci.pop_front(); } chmax(ans, abs(score[0]) - abs(score[1])); } // big small { deque<ll> ci = c; vector<ll> score(2, 0); rep(i, n) { if (i % 2) { score[i % 2] += ci.front(); ci.pop_front(); } else { score[i % 2] += ci.back(); ci.pop_back(); } } chmax(ans, abs(score[0]) - abs(score[1])); } // small big { deque<ll> ci = c; vector<ll> score(2, 0); rep(i, n) { if (i % 2) { score[i % 2] += ci.back(); ci.back(); } else { score[i % 2] += ci.front(); ci.pop_front(); } } chmax(ans, abs(score[0]) - abs(score[1])); } // small small { deque<ll> ci = c; vector<ll> score(2, 0); rep(i, n) { score[i % 2] += ci.back(); ci.pop_back(); } chmax(ans, abs(score[0]) - abs(score[1])); } cout << ans << endl; }