結果
問題 |
No.1071 ベホマラー
|
ユーザー |
![]() |
提出日時 | 2020-06-06 17:12:49 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,123 bytes |
コンパイル時間 | 867 ms |
コンパイル使用メモリ | 112,832 KB |
実行使用メモリ | 54,624 KB |
最終ジャッジ日時 | 2024-12-23 13:14:02 |
合計ジャッジ時間 | 47,348 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 5 TLE * 15 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; public class Hello { static int n, k, x, y, azero; static long ans; static void Main() { string[] line = Console.ReadLine().Trim().Split(' '); n = int.Parse(line[0]); k = int.Parse(line[1]); x = int.Parse(line[2]); y = int.Parse(line[3]); var a = new int[n]; line = Console.ReadLine().Trim().Split(' '); azero = 0; for (int i = 0; i < n; i++) { a[i] = (int.Parse(line[i]) + k - 2) / k; if (a[i] == 0) azero++; } ans = 0L; getAns(a); Console.WriteLine(ans); } static void getAns(int[] a) { while (azero < n) { if (check(a)) { ans += (long)(n - azero) * x; } else ans += y; dec(a); } } static void dec(int[] a) { for (int i = 0; i < n; i++) { if (a[i] > 1) a[i]--; else if (a[i] == 1) { a[i] = 0; azero++; } } } static bool check(int[] a) { var b1 = (long)(n - azero) * x; return b1 <= y; } }