結果

問題 No.45 回転寿司
ユーザー Roki
提出日時 2017-03-14 11:19:30
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 5,000 ms
コード長 276 bytes
コンパイル時間 909 ms
コンパイル使用メモリ 66,048 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-27 16:12:13
合計ジャッジ時間 1,997 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<array>
int main()
{
	std::array<std::size_t,1001> ar{};
	std::size_t n{};
	std::cin>>n;
	for(std::size_t i=1; i<=n; ++i)std::cin>>ar[i];
	for(std::size_t i=2; i<=n; ++i)ar[i]=std::max(ar[i-1],ar[i]+ar[i-2]);
	std::cout<<ar[n];
}
0