結果

問題 No.489 株に挑戦
ユーザー mbanmban
提出日時 2017-04-29 04:37:44
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 2,345 bytes
コンパイル時間 2,143 ms
コンパイル使用メモリ 101,848 KB
実行使用メモリ 24,920 KB
最終ジャッジ日時 2023-10-11 20:14:05
合計ジャッジ時間 12,305 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 392 ms
24,832 KB
testcase_01 WA -
testcase_02 AC 59 ms
20,820 KB
testcase_03 AC 60 ms
20,752 KB
testcase_04 AC 55 ms
18,744 KB
testcase_05 AC 61 ms
22,800 KB
testcase_06 AC 60 ms
20,784 KB
testcase_07 AC 61 ms
22,808 KB
testcase_08 AC 61 ms
20,716 KB
testcase_09 AC 61 ms
20,692 KB
testcase_10 AC 60 ms
18,688 KB
testcase_11 AC 60 ms
22,692 KB
testcase_12 AC 61 ms
20,704 KB
testcase_13 AC 61 ms
22,792 KB
testcase_14 AC 61 ms
20,796 KB
testcase_15 AC 65 ms
22,764 KB
testcase_16 AC 596 ms
24,920 KB
testcase_17 AC 67 ms
20,692 KB
testcase_18 AC 312 ms
20,916 KB
testcase_19 AC 303 ms
22,740 KB
testcase_20 AC 515 ms
22,760 KB
testcase_21 AC 146 ms
20,696 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 485 ms
22,848 KB
testcase_25 AC 58 ms
20,660 KB
testcase_26 WA -
testcase_27 AC 584 ms
22,836 KB
testcase_28 AC 62 ms
20,740 KB
testcase_29 AC 57 ms
20,672 KB
testcase_30 AC 337 ms
24,852 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 539 ms
22,904 KB
testcase_34 AC 481 ms
22,744 KB
testcase_35 WA -
testcase_36 AC 124 ms
20,792 KB
testcase_37 AC 400 ms
22,808 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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((long)K * max);
        if (max == 0)
        {
            return;
        }
        Console.WriteLine($"{maxleft} {maxright}");
    }
}
0