結果

問題 No.1071 ベホマラー
ユーザー mbanmban
提出日時 2020-06-05 21:40:31
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 126 ms / 2,000 ms
コード長 2,388 bytes
コンパイル時間 2,370 ms
コンパイル使用メモリ 103,556 KB
実行使用メモリ 38,984 KB
最終ジャッジ日時 2023-08-22 14:44:06
合計ジャッジ時間 6,202 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 61 ms
23,560 KB
testcase_01 AC 61 ms
19,540 KB
testcase_02 AC 61 ms
21,552 KB
testcase_03 AC 62 ms
21,548 KB
testcase_04 AC 62 ms
21,696 KB
testcase_05 AC 63 ms
21,516 KB
testcase_06 AC 62 ms
21,620 KB
testcase_07 AC 64 ms
23,580 KB
testcase_08 AC 62 ms
23,672 KB
testcase_09 AC 63 ms
21,664 KB
testcase_10 AC 116 ms
29,208 KB
testcase_11 AC 114 ms
29,164 KB
testcase_12 AC 99 ms
26,924 KB
testcase_13 AC 109 ms
28,548 KB
testcase_14 AC 118 ms
31,492 KB
testcase_15 AC 126 ms
30,172 KB
testcase_16 AC 126 ms
30,216 KB
testcase_17 AC 125 ms
30,228 KB
testcase_18 AC 125 ms
30,268 KB
testcase_19 AC 124 ms
30,160 KB
testcase_20 AC 124 ms
38,984 KB
testcase_21 AC 122 ms
38,968 KB
testcase_22 AC 125 ms
36,852 KB
testcase_23 AC 122 ms
36,968 KB
testcase_24 AC 123 ms
30,236 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.Linq;
using CompLib.Util;

public class Program
{

    public void Solve()
    {
        var sc = new Scanner();
        int n = sc.NextInt();
        int k = sc.NextInt();
        long x = sc.NextInt();
        long y = sc.NextInt();

        int[] a = sc.IntArray();

        long[] h = new long[n];
        for (int i = 0; i < n; i++)
        {
            h[i] = (a[i] - 2 + k) / k;
        }

        // t <= n

        // xを t回する方が y1回の方が少ない
        // x*t <= y

        // 

        Array.Sort(h, (l, r) => r.CompareTo(l));

        long maxT = y / x;

        if (maxT >= n)
        {
            Console.WriteLine(h.Sum());
            return;
        }

        long ans = 0;

        long t = 0;

        for (int i = 0; i < maxT; i++)
        {
            t += h[i];
        }

        ans = y * h[maxT] + x * (t - (h[maxT] * maxT));

        Console.WriteLine(ans);
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}
0