結果

問題 No.335 門松宝くじ
ユーザー kotatsugamekotatsugame
提出日時 2020-02-24 15:26:04
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 456 bytes
コンパイル時間 589 ms
コンパイル使用メモリ 65,924 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-20 09:51:37
合計ジャッジ時間 1,457 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 3 ms
6,944 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 3 ms
6,940 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 3 ms
6,944 KB
testcase_12 AC 4 ms
6,940 KB
testcase_13 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:5:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    5 | main()
      | ^~~~
main.cpp: In function 'int main()':
main.cpp:30:15: warning: 'id' may be used uninitialized [-Wmaybe-uninitialized]
   30 |         cout<<id<<endl;
      |               ^~
main.cpp:8:20: note: 'id' was declared here
    8 |         int ans=-1,id;
      |                    ^~

ソースコード

diff #

#include<iostream>
using namespace std;
int N,M;
int E[800];
main()
{
	cin>>N>>M;
	int ans=-1,id;
	for(int I=0;I<M;I++)
	{
		for(int i=0;i<N;i++)cin>>E[i];
		int now=0;
		for(int i=0;i<N-2;i++)
		{
			int L=E[i+1],U=E[i+1];
			for(int j=i+2;j<N;j++)
			{
				if(U>E[i]&&U>E[j])now+=U;
				else if(L<E[i]&&L<E[j])now+=E[i]<E[j]?E[j]:E[i];
				if(U<E[j])U=E[j];
				if(L>E[j])L=E[j];
			}
		}
		if(ans<now)
		{
			ans=now;
			id=I;
		}
	}
	cout<<id<<endl;
}
0