結果
| 問題 |
No.45 回転寿司
|
| ユーザー |
kichirb3
|
| 提出日時 | 2018-03-17 18:49:57 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 714 bytes |
| コンパイル時間 | 716 ms |
| コンパイル使用メモリ | 71,120 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-27 18:43:29 |
| 合計ジャッジ時間 | 1,748 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 30 |
ソースコード
// No.45 回転寿司
// https://yukicoder.me/problems/no/45
//
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int solve(vector<int> &osushi);
int main() {
std::cin.tie(nullptr);
std::ios::sync_with_stdio(false);
unsigned int N;
cin >> N;
vector<int> osushi(N);
for (auto i = 0; i < N; ++i)
cin >> osushi[i];
int ans = solve(osushi);
cout << ans << endl;
}
int solve(vector<int> &osushi) {
int next_OK = 0;
int next_NG = osushi[0];
for (auto i = 1; i < osushi.size(); ++i) {
int temp = next_NG;
next_NG = next_OK + osushi[i];
next_OK = max(next_OK, temp);
}
return max(next_OK, next_NG);
}
kichirb3