結果

問題 No.489 株に挑戦
ユーザー mbanmban
提出日時 2017-04-29 04:36:14
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 2,339 bytes
コンパイル時間 4,301 ms
コンパイル使用メモリ 103,876 KB
実行使用メモリ 26,968 KB
最終ジャッジ日時 2023-10-11 20:13:41
合計ジャッジ時間 15,490 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 61 ms
20,700 KB
testcase_03 AC 61 ms
20,660 KB
testcase_04 AC 57 ms
20,740 KB
testcase_05 AC 62 ms
20,696 KB
testcase_06 AC 62 ms
20,772 KB
testcase_07 AC 61 ms
20,712 KB
testcase_08 AC 60 ms
20,768 KB
testcase_09 AC 61 ms
20,656 KB
testcase_10 AC 62 ms
20,800 KB
testcase_11 AC 62 ms
20,716 KB
testcase_12 AC 62 ms
20,760 KB
testcase_13 AC 62 ms
20,912 KB
testcase_14 AC 61 ms
18,668 KB
testcase_15 AC 65 ms
20,700 KB
testcase_16 AC 594 ms
22,684 KB
testcase_17 AC 66 ms
22,868 KB
testcase_18 AC 311 ms
20,800 KB
testcase_19 AC 302 ms
20,720 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 58 ms
22,728 KB
testcase_26 WA -
testcase_27 AC 583 ms
22,800 KB
testcase_28 WA -
testcase_29 AC 58 ms
22,780 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;

public class Program
{
    public static void Main(string[] args)
    {
        new Magatro().Solve();
    }
}

class Magatro
{
    private int N, D, K;
    private int[] x;

    private void Scan()
    {
        string[] line = Console.ReadLine().Split(' ');
        N = int.Parse(line[0]);
        D = int.Parse(line[1]);
        K = int.Parse(line[2]);

        x = new int[N];
        for (int i = 0; i < N; i++)
        {
            x[i] = int.Parse(Console.ReadLine());
        }
    }

    public void Solve()
    {
        Scan();

        int[] B = new int[(N + 1000 - 1) / 1000];
        int[] index = new int[(N + 1000 - 1) / 1000];
        int maxleft = -1;
        int maxright = -1;

        for (int i = 0; i < N; i++)
        {
            if (B[i / 1000] < x[i])
            {
                B[i / 1000] = x[i];
                index[i / 1000] = i;
            }
            
        }
        int max = 0;
        for (int i = 0; i < N - 1; i++)
        {
            int right = Math.Min(i + D, N - 1);

            int bleft = i / 1000;
            int bright = right / 1000;
            int m = 0;

            int rightindex = -1;
            for (int j = bleft; j < bright; j++)
            {
                if (m < B[j])
                {
                    m = B[j];
                    rightindex = index[j];
                }
            }

            for (int j = i; j <= right && j % 1000 < 999; j++)
            {
                if (m < x[j])
                {
                    m = x[j];
                    rightindex = j;
                }
            }


            for (int j = right; j >= i && j % 1000 < 999; j--)
            {
                if (m < x[j])
                {
                    m = x[j];
                    rightindex = j;
                }
            }
            if (max < m - x[i])
            {
                maxleft = i;
                maxright = rightindex;
                max = m - x[i];
            }

        }

        Console.WriteLine(K * max);
        if (max == 0)
        {
            return;
        }
        Console.WriteLine($"{maxleft} {maxright}");
    }
}
0