結果
問題 |
No.1071 ベホマラー
|
ユーザー |
![]() |
提出日時 | 2020-06-06 20:27:07 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 88 ms / 2,000 ms |
コード長 | 939 bytes |
コンパイル時間 | 716 ms |
コンパイル使用メモリ | 111,264 KB |
実行使用メモリ | 42,408 KB |
最終ジャッジ日時 | 2024-12-23 13:48:33 |
合計ジャッジ時間 | 2,991 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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]); var a = new long[n]; line = Console.ReadLine().Trim().Split(' '); for (int i = 0; i < n; i++) a[i] = (int.Parse(line[i]) + k - 2) / k; 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 = 0L; for (int i = p + 1; i < n; i++) tsum += a[i]; tsum -= nz * a[p]; ans += tsum * x; return ans; } }