結果
問題 | No.999 てん vs. ほむ |
ユーザー |
![]() |
提出日時 | 2020-02-28 22:39:00 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 75 ms / 2,000 ms |
コード長 | 493 bytes |
コンパイル時間 | 1,480 ms |
コンパイル使用メモリ | 169,740 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-13 18:29:09 |
合計ジャッジ時間 | 3,510 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for(int i=0; i<(n); ++i) using ll = long long; int main() { int n; cin >> n; vector<ll> a(2*n); rep(i, 2*n){ cin >> a[i]; } vector<ll> diff(n); ll res = 0; rep(i, n){ diff[i] = a[2*i] - a[2*i+1]; res += diff[i]; } ll ans = res; for(int i=n-1; i>=0; --i){ res -= 2 * diff[i]; ans = max(ans, res); } cout << ans << endl; return 0; }