結果
問題 |
No.489 株に挑戦
|
ユーザー |
|
提出日時 | 2017-02-27 00:56:59 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 523 bytes |
コンパイル時間 | 792 ms |
コンパイル使用メモリ | 31,104 KB |
実行使用メモリ | 5,888 KB |
最終ジャッジ日時 | 2025-03-21 03:32:25 |
合計ジャッジ時間 | 5,942 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 3 |
other | AC * 16 WA * 19 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:8:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 8 | scanf("%d%d%d",&n,&d,&k); | ~~~~~^~~~~~~~~~~~~~~~~~~ main.cpp:9:34: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 9 | for(int i=0;i<n;i++)scanf("%d",x+i); | ~~~~~^~~~~~~~~~ main.cpp:15:17: warning: ‘r’ may be used uninitialized [-Wmaybe-uninitialized] 15 | if(r<f-x[i])r=f-x[i],s=i; | ^~ main.cpp:7:19: note: ‘r’ was declared here 7 | int n,d,k,r,s; | ^ main.cpp:20:23: warning: ‘s’ may be used uninitialized [-Wmaybe-uninitialized] 20 | if(e>n-s)e=n-s; | ~^~ main.cpp:7:21: note: ‘s’ was declared here 7 | int n,d,k,r,s; | ^
ソースコード
#pragma GCC optimize("O3") #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; } } }