結果

問題 No.489 株に挑戦
ユーザー yun_appyun_app
提出日時 2017-03-19 16:03:35
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 2,009 bytes
コンパイル時間 2,268 ms
コンパイル使用メモリ 81,820 KB
実行使用メモリ 66,720 KB
最終ジャッジ日時 2023-09-18 07:29:18
合計ジャッジ時間 7,101 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 70 ms
51,112 KB
testcase_03 AC 73 ms
53,552 KB
testcase_04 AC 40 ms
49,260 KB
testcase_05 AC 70 ms
51,208 KB
testcase_06 AC 77 ms
52,080 KB
testcase_07 WA -
testcase_08 AC 72 ms
52,552 KB
testcase_09 AC 69 ms
51,596 KB
testcase_10 AC 77 ms
52,420 KB
testcase_11 AC 83 ms
52,076 KB
testcase_12 AC 73 ms
53,372 KB
testcase_13 AC 84 ms
52,400 KB
testcase_14 AC 74 ms
52,528 KB
testcase_15 AC 131 ms
54,072 KB
testcase_16 TLE -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

/* 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;
                i=ans.start;
            }
        }
        
        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;
        }
    }
}
0