結果

問題 No.489 株に挑戦
ユーザー myanta
提出日時 2017-06-30 11:34:00
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 498 bytes
コンパイル時間 259 ms
コンパイル使用メモリ 36,352 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-04 18:20:17
合計ジャッジ時間 2,200 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 19 WA * 16
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:19:43: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   19 |                 for(int i=0;i<n;i++) scanf("%d", &x[i]);
      |                                      ~~~~~^~~~~~~~~~~~~

ソースコード

diff #

#include<cstdio>
#include<vector>


using namespace std;
using vi=vector<int>;


int main(void)
{
	int n, d, k;

	while(scanf("%d%d%d", &n, &d, &k)==3)
	{
		vi x(n);
		int b, s, e;
		int b_max=0, s_max, e_max;

		for(int i=0;i<n;i++) scanf("%d", &x[i]);

		for(s=e=0;e<n;e++)
		{
			if(e-s>d) s++;
			b=x[e]-x[s];
			if(b_max<b)
			{
				b_max=b;
				e_max=e;
				s_max=s;
			}
			if(b<0) s=e;
		}
		printf("%d\n", b_max*k);
		if(b_max)
		{
			printf("%d %d\n", s_max, e_max);
		}
	}

	return 0;
}
0