結果
| 問題 | No.999 てん vs. ほむ |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-03-12 21:41:13 |
| 言語 | C++17(clang) (clang++ 23.1.3 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 12 ms / 2,000 ms |
| + 263µs | |
| コード長 | 740 bytes |
| 記録 | |
| コンパイル時間 | 6,586 ms |
| コンパイル使用メモリ | 129,280 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-10-12 04:59:26 |
| 合計ジャッジ時間 | 4,094 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge4_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 |
ソースコード
#include <iostream>
#include <algorithm>
#include <vector>
using lint = long long;
constexpr lint INF = 1LL << 50;
void solve() {
int n;
std::cin >> n;
std::vector<lint> fs(n + 2, 0), bs(n + 2, 0);
for (int i = 1; i <= n; ++i) {
lint x, y;
std::cin >> x >> y;
fs[i] = x - y;
bs[i] = y - x;
}
for (int i = 1; i <= n; ++i) fs[i] += fs[i - 1];
for (int i = n; i >= 1; --i) bs[i] += bs[i + 1];
lint ans = -INF;
for (int f = 0; f <= n; ++f) {
ans = std::max(ans, fs[f] + bs[f + 1]);
}
std::cout << ans << std::endl;
}
int main() {
std::cin.tie(nullptr);
std::cout.tie(nullptr);
std::ios::sync_with_stdio(false);
solve();
return 0;
}