結果
| 問題 |
No.489 株に挑戦
|
| コンテスト | |
| ユーザー |
myanta
|
| 提出日時 | 2017-06-30 11:42:40 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 654 bytes |
| コンパイル時間 | 415 ms |
| コンパイル使用メモリ | 44,160 KB |
| 実行使用メモリ | 8,064 KB |
| 最終ジャッジ日時 | 2024-10-04 18:20:58 |
| 合計ジャッジ時間 | 2,023 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 19 WA * 16 |
コンパイルメッセージ
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]);
| ~~~~~^~~~~~~~~~~~~
ソースコード
#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;
}
myanta