結果
| 問題 |
No.489 株に挑戦
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-02-27 00:56:32 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 557 bytes |
| コンパイル時間 | 278 ms |
| コンパイル使用メモリ | 31,616 KB |
| 実行使用メモリ | 7,848 KB |
| 最終ジャッジ日時 | 2025-04-22 05:04:33 |
| 合計ジャッジ時間 | 6,218 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | AC * 11 WA * 24 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:9:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
9 | scanf("%d%d%d",&n,&d,&k);
| ~~~~~^~~~~~~~~~~~~~~~~~~
main.cpp:10:34: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
10 | for(int i=0;i<n;i++)scanf("%d",x+i);
| ~~~~~^~~~~~~~~~
main.cpp:16:17: warning: ‘r’ may be used uninitialized [-Wmaybe-uninitialized]
16 | if(r<f-x[i])r=f-x[i],s=i;
| ^~
main.cpp:8:19: note: ‘r’ was declared here
8 | int n,d,k,r,s;
| ^
main.cpp:21:23: warning: ‘s’ may be used uninitialized [-Wmaybe-uninitialized]
21 | if(e>n-s)e=n-s;
| ~^~
main.cpp:8:21: note: ‘s’ was declared here
8 | int n,d,k,r,s;
| ^
ソースコード
#pragma GCC optimize("O3")
#pragma GCC target("tune=native")
#pragma GCC target("avx")
#include <stdio.h>
//yukicoder does not support C99
int x[100000];
int main(){
int n,d,k,r,s;
scanf("%d%d%d",&n,&d,&k);
for(int i=0;i<n;i++)scanf("%d",x+i);
for(int i=0;i<n;i++){
int e=d+1;
int f=x[i];
if(e>n-i)e=n-i;
for(int j=0;j<e;j++)if(f<x[i+j])f=x[i+j];
if(r<f-x[i])r=f-x[i],s=i;
}
if(r==0)puts("0");
else{
int e=d+1;
if(e>n-s)e=n-s;
for(int j=0;j<e;j++)if(r==x[s+j]-x[s]){
printf("%lld\n%d %d\n",(long long)r*k,s,s+j);
break;
}
}
}