結果
| 問題 |
No.999 てん vs. ほむ
|
| コンテスト | |
| ユーザー |
Strorkis
|
| 提出日時 | 2020-02-28 21:49:12 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 25 ms / 2,000 ms |
| コード長 | 520 bytes |
| コンパイル時間 | 535 ms |
| コンパイル使用メモリ | 69,120 KB |
| 実行使用メモリ | 7,936 KB |
| 最終ジャッジ日時 | 2024-10-13 17:14:20 |
| 合計ジャッジ時間 | 1,796 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 |
ソースコード
#include <iostream>
#include <vector>
using namespace std;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int N; cin >> N;
int N2 = N * 2;
vector<long long> A(N2);
for (int i = 0; i < N2; i++) cin >> A[i];
vector<long long> cs1(N2+1), cs2(N2+1);
for (int i = 0; i < N; i++) {
cs1[i+1] = cs1[i] + A[i*2] - A[i*2+1];
cs2[i+1] = cs2[i] + A[N2-i*2-1] - A[N2-i*2-2];
}
long long ans = 0;
for (int i = 0; i <= N; i++) {
ans = max(ans, cs1[i] + cs2[N-i]);
}
cout << ans << "\n";
}
Strorkis