結果
問題 |
No.489 株に挑戦
|
ユーザー |
![]() |
提出日時 | 2017-03-01 14:16:55 |
言語 | Java (openjdk 23) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,784 bytes |
コンパイル時間 | 2,335 ms |
コンパイル使用メモリ | 78,496 KB |
実行使用メモリ | 66,392 KB |
最終ジャッジ日時 | 2024-06-12 05:06:51 |
合計ジャッジ時間 | 8,937 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 WA * 2 TLE * 2 -- * 21 |
ソースコード
/* package whatever; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ class Main { public static void main (String[] args) throws java.lang.Exception { // your code goes here BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] line = br.readLine().split(" "); int N = Integer.parseInt(line[0]); int D = Integer.parseInt(line[1]); long K = Long.parseLong(line[2]); ArrayList<Long> map = new ArrayList<Long>(); for(int i=0;i<N;i++){ map.add(Long.parseLong(br.readLine())); } Ans ans = new Ans(); for(int i=0;i<N-D+1;i++){ Ans tmp = calc(map,i,D); if(tmp.getDiff() > ans.getDiff()){ ans = tmp; } } if(ans.getDiff()==0){ System.out.println(0); }else{ System.out.println(K*ans.getDiff()); System.out.println(ans.start + " " + ans.end); } } private static Ans calc(ArrayList<Long> map,int s,int d){ Ans ans = new Ans(); ans.start = s; ans.start_c = map.get(s); ans.end = ans.start; ans.end_c = ans.start_c; for(int i=s;i<=s+d&&i<map.size();i++){ if(ans.end_c < map.get(i)){ ans.end = i; ans.end_c = map.get(i); } } return ans; } private static class Ans{ long start; long start_c; long end; long end_c; public long getDiff(){ return end_c-start_c; } } }