結果
問題 |
No.1430 Coup de Coupon
|
ユーザー |
|
提出日時 | 2024-07-10 22:24:44 |
言語 | C# (.NET 8.0.404) |
結果 |
AC
|
実行時間 | 195 ms / 2,000 ms |
コード長 | 1,681 bytes |
コンパイル時間 | 8,466 ms |
コンパイル使用メモリ | 167,332 KB |
実行使用メモリ | 187,812 KB |
最終ジャッジ日時 | 2024-07-10 22:25:08 |
合計ジャッジ時間 | 13,521 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 27 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (101 ms)。 MSBuild のバージョン 17.9.6+a4ecab324 (.NET) main -> /home/judge/data/code/bin/Release/net8.0/main.dll main -> /home/judge/data/code/bin/Release/net8.0/publish/
ソースコード
using System; using static System.Console; using System.Linq; using System.Collections.Generic; class Program { static int NN => int.Parse(ReadLine()); static int[] NList => ReadLine().Split().Select(int.Parse).ToArray(); static int[][] NArr(long n) => Enumerable.Repeat(0, (int)n).Select(_ => NList).ToArray(); static int[] LList(long n) => Enumerable.Repeat(0, (int)n).Select(_ => int.Parse(ReadLine())).ToArray(); public static void Main() { Solve(); } static void Solve() { var c = NList; var (n, m) = (c[0], c[1]); var p = LList(n); var map = NArr(m); var a = new List<int>(); var b = new List<int>(); foreach (var coup in map) { if (coup[0] == 1) a.Add(coup[1]); else b.Add(coup[1]); } Array.Sort(p, (l, r) => r.CompareTo(l)); a.Sort((l, r) => r.CompareTo(l)); b.Sort((l, r) => r.CompareTo(l)); var dp = new long[a.Count + 1][]; for (var i = 0; i < dp.Length; ++i) dp[i] = new long[b.Count + 1]; for (var i = 0; i < dp.Length; ++i) for (var j = 0; j < dp[i].Length; ++j) { if (i + 1 < dp.Length && i + j < n) dp[i + 1][j] = Math.Max(dp[i + 1][j], dp[i][j] + Math.Min(p[i + j], a[i])); if (j + 1 < dp[i].Length && i + j < n) dp[i][j + 1] = Math.Max(dp[i][j + 1], dp[i][j] + p[i + j] * b[j] / 100); } var ans = 0L; foreach (var pi in p) ans += pi; var max = 0L; foreach (var di in dp) foreach (var dij in di) max = Math.Max(max, dij); WriteLine(ans - max); } }