結果

問題 No.45 回転寿司
ユーザー ciel
提出日時 2014-11-16 22:20:21
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 330 bytes
コンパイル時間 512 ms
コンパイル使用メモリ 36,224 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-27 10:56:49
合計ジャッジ時間 1,679 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:6:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    6 |         scanf("%d",&n);
      |         ~~~~~^~~~~~~~~
main.cpp:9:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    9 |                 scanf("%d",&v[i]);
      |                 ~~~~~^~~~~~~~~~~~

ソースコード

diff #

#include <vector>
#include <cstdio>
#define BACK 2
int main(){
	int n;
	scanf("%d",&n);
	std::vector<int>v(n);
	for(int i=0;i<n;i++){
		scanf("%d",&v[i]);
		int ma=0;
		for(int j=0;j<=i-BACK;j++)if(ma<v[j])ma=v[j];
		v[i]+=ma;
	}
	int ma=0;
	for(int i=n-BACK;i<n;i++)if(i>=0&&ma<v[i])ma=v[i];
	printf("%d\n",ma);
}
0