結果
問題 |
No.489 株に挑戦
|
ユーザー |
![]() |
提出日時 | 2017-03-19 16:11:59 |
言語 | Java (openjdk 23) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,972 bytes |
コンパイル時間 | 2,157 ms |
コンパイル使用メモリ | 79,652 KB |
実行使用メモリ | 53,648 KB |
最終ジャッジ日時 | 2024-07-04 23:38:06 |
合計ジャッジ時間 | 8,094 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 12 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;i++){ Ans tmp = calc(map,i,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){ int min=Integer.MAX_VALUE,max=0; long min_c = Long.MAX_VALUE; long max_c = 0l; Ans ans = new Ans(); for(int i=s,size=map.size();i<=d&&i<size;i++){ long t = map.get(i); if(min_c > t){ min = i; min_c = t; } if(max_c < t){ max = i; max_c = t; ans.start = min; ans.start_c = min_c; ans.end = max; ans.end_c = max_c; } } return ans; } private static class Ans{ int start; long start_c; int end; long end_c; public long getDiff(){ return end_c-start_c; } } }