結果
| 問題 |
No.999 てん vs. ほむ
|
| コンテスト | |
| ユーザー |
IKyopro
|
| 提出日時 | 2020-03-03 22:22:26 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 29 ms / 2,000 ms |
| コード長 | 620 bytes |
| コンパイル時間 | 2,024 ms |
| コンパイル使用メモリ | 195,240 KB |
| 最終ジャッジ日時 | 2025-01-09 04:18:51 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int N;
cin >> N;
vec<ll> A(2*N);
for(int i=0;i<2*N;i++) cin >> A[i];
ll now = 0;
for(int i=2*N-1;i>=0;i--){
if(i%2) now += A[i];
else now -= A[i];
}
ll ans = now;
for(int i=0;i<2*N;i+=2){
now += 2*A[i];
now -= 2*A[i+1];
ans = max(ans,now);
}
cout << ans << "\n";
}
IKyopro