結果
問題 | No.1071 ベホマラー |
ユーザー |
![]() |
提出日時 | 2020-06-07 07:18:14 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 100 ms / 2,000 ms |
コード長 | 880 bytes |
コンパイル時間 | 1,146 ms |
コンパイル使用メモリ | 107,648 KB |
実行使用メモリ | 34,176 KB |
最終ジャッジ日時 | 2024-12-23 15:47:54 |
合計ジャッジ時間 | 3,994 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 20 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System.Linq;using System;public class Hello{static void Main(){string[] line = Console.ReadLine().Trim().Split(' ');var n = int.Parse(line[0]);var k = int.Parse(line[1]);var x = int.Parse(line[2]);var y = int.Parse(line[3]);line = Console.ReadLine().Trim().Split(' ');var a = line.Select(z => (long.Parse(z) + k - 2) / k).ToArray();var ans = getAns(n, x, y, a);Console.WriteLine(ans);}static long getAns(int n, int x, int y, long[] a){Array.Sort(a);var nz = y / x;if (nz == 0) return a.Max() * y;if (nz >= n) return a.Sum() * x;var p = n - nz - 1;var ans = a[p] * y;var tsum = a.Where(z => z > a[p]).Sum();if (tsum > 0) tsum -= nz * a[p];ans += tsum * x;return ans;}}