結果

問題 No.45 回転寿司
ユーザー vjudge1
提出日時 2025-11-19 22:00:00
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 894 bytes
コンパイル時間 3,238 ms
コンパイル使用メモリ 278,464 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2025-11-19 22:00:05
合計ジャッジ時間 4,539 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;

using i64 = long long;
using u64 = unsigned long long;
using u32 = unsigned;

using u128 = unsigned __int128;
using i128 = __int128;


void solve(){
	int n;cin>>n;
	vector<int> a(n+1);
	for(int i=1;i<=n;++i){cin>>a[i];}
	if(n==1){
		cout<<a[1];return;
	}
	
	vector<int> b(n+1,0);
	b[1]=a[1];
	for(int i=2;i<=n;++i){
		b[i]=max(b[i-1],a[i]+b[i-2]);
	}
	cout<<b[n];
	return;
}


int main(){
	ios::sync_with_stdio(false);cin.tie(nullptr);
	
		solve();
	
	return 0;
}


















/*
***** Orz  Kiropo *******
*?????????+ +
*?????????? + +
*??????????
*?????????? ++ + + +
*  ?????????+
*  ????????? +
*??????????
*?????????? + +
*??????????
*???????? + + + +Code is far away from ?
*???????? + bug with the animal protecting
*????? ? ????? ????,???bug?
*???? ?????? ??
*??  ? ????? ???
*?    ????????? + + + +
*???????????
*???????????+ + + +
*/
0