結果

問題 No.489 株に挑戦
ユーザー myantamyanta
提出日時 2017-06-30 11:42:40
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 654 bytes
コンパイル時間 447 ms
コンパイル使用メモリ 44,288 KB
実行使用メモリ 8,212 KB
最終ジャッジ日時 2024-04-15 05:39:31
合計ジャッジ時間 2,116 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 1 ms
6,944 KB
testcase_08 AC 1 ms
6,944 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 2 ms
6,944 KB
testcase_11 AC 2 ms
6,944 KB
testcase_12 AC 1 ms
6,940 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 41 ms
6,944 KB
testcase_17 AC 4 ms
6,944 KB
testcase_18 AC 18 ms
6,944 KB
testcase_19 AC 17 ms
6,944 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 2 ms
6,940 KB
testcase_26 AC 39 ms
7,552 KB
testcase_27 AC 24 ms
6,940 KB
testcase_28 WA -
testcase_29 AC 1 ms
6,944 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:21:43: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   21 |                 for(int i=0;i<n;i++) scanf("%d", &x[i]);
      |                                      ~~~~~^~~~~~~~~~~~~

ソースコード

diff #

#include<cstdio>
#include<vector>
#include<set>


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);
		multiset<int> m;
		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++)
		{
			m.insert(x[e]);
			if(e-s>d)
			{
				m.erase(m.find(x[s]));
				s++;
			}
			b=x[e]-*(m.begin());
			if(b_max<b)
			{
				b_max=b;
				e_max=e;
				for(s_max=s;s_max<e;s_max++)
				{
					if(x[s_max]==*(m.begin())) break;
				}
			}
		}
		printf("%d\n", b_max*k);
		if(b_max)
		{
			printf("%d %d\n", s_max, e_max);
		}
	}

	return 0;
}
0