結果
問題 |
No.999 てん vs. ほむ
|
ユーザー |
![]() |
提出日時 | 2020-02-28 21:25:03 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 26 ms / 2,000 ms |
コード長 | 543 bytes |
コンパイル時間 | 1,505 ms |
コンパイル使用メモリ | 169,536 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-13 16:38:54 |
合計ジャッジ時間 | 2,736 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
ソースコード
#include <bits/stdc++.h> using namespace std; constexpr long long inf = 0x3f3f3f3fLL << 32; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int n; cin >> n; vector<int> a(2 * n); for (auto&& e : a) { cin >> e; } long long res = -inf, cur = 0; for (int i = 0; i < 2 * n; ++i) { if (i & 1) { cur += a[i]; } else { cur -= a[i]; } } res = cur; for (int i = 0; i < 2 * n; i += 2) { cur += 2 * a[i]; cur -= 2 * a[i + 1]; res = max(res, cur); } cout << res << '\n'; }