結果
問題 |
No.45 回転寿司
|
ユーザー |
|
提出日時 | 2020-04-11 12:18:10 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 4 ms / 5,000 ms |
コード長 | 564 bytes |
コンパイル時間 | 780 ms |
コンパイル使用メモリ | 68,972 KB |
最終ジャッジ日時 | 2025-01-09 17:17:19 |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
#include <iostream> #include <vector> void solve() { int n; std::cin >> n; if (n == 1) { int x; std::cin >> x; std::cout << x << std::endl; return; } int a, b; std::cin >> a >> b; b = std::max(a, b); n -= 2; while (n--) { int x; std::cin >> x; int c = std::max(a + x, b); a = b; b = c; } std::cout << std::max(a, b) << std::endl; } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); solve(); return 0; }