結果
問題 |
No.999 てん vs. ほむ
|
ユーザー |
|
提出日時 | 2020-03-12 21:41:13 |
言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 26 ms / 2,000 ms |
コード長 | 740 bytes |
コンパイル時間 | 807 ms |
コンパイル使用メモリ | 130,912 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-30 16:54:15 |
合計ジャッジ時間 | 2,196 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
ソースコード
#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; }