結果
問題 | No.2770 Coupon Optimization |
ユーザー |
|
提出日時 | 2024-05-31 22:09:16 |
言語 | C# (.NET 8.0.404) |
結果 |
AC
|
実行時間 | 296 ms / 3,000 ms |
コード長 | 2,596 bytes |
コンパイル時間 | 8,353 ms |
コンパイル使用メモリ | 165,984 KB |
実行使用メモリ | 240,780 KB |
最終ジャッジ日時 | 2024-12-20 23:41:02 |
合計ジャッジ時間 | 14,217 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 16 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (103 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/
ソースコード
namespace AtCoder;#nullable enableusing System.Numerics;static class Extensions{public static T[] Repeat<T>(this int time, Func<T> F) => Enumerable.Range(0, time).Select(_ => F()).ToArray();}class AtCoder{object? Solve(){var n = Int();var m = Int();var az = n.Repeat(Int);var bz = m.Repeat(Int);var iz = new int[n];for (var i = 0; i < n; i++) iz[i] = az[i] / 100;Array.Sort(iz);var cz = new int[101];foreach (var b in bz) cz[100 - b]++;cz[0] = n - 1;cz[100] = Math.Max(0, n - m);var sz = new long[n + 1];for (var i = 1; i <= n; i++) sz[i] = sz[i - 1] + iz[i - 1];var zz = new (int, int)[101];{var j = n;for (var i = 0; i <= 100; i++){var r = j;j -= cz[i];zz[i] = (j, r);}}var ans = new long[n];for (var i = 0; i < n; i++){var ins = 0L;for (var j = 0; j <= 100; j++){var jns = 0L;var (l, r) = zz[j];if (0 <= r && r <= n) jns += sz[r];if (0 <= l && l <= n) jns -= sz[l];ins += jns * j;zz[j] = (l + 1, Math.Min(n, r + 1));}ans[i] = ins;}Out(ans);return null;}public static void Main() => new AtCoder().Run();public void Run(){var res = Solve();if (res != null){if (res is bool yes) res = yes ? "Yes" : "No";sw.WriteLine(res);}sw.Flush();}string[] input = Array.Empty<string>();int iter = 0;readonly StreamWriter sw = new(Console.OpenStandardOutput()) { AutoFlush = false };string String(){while (iter >= input.Length) (input, iter) = (Console.ReadLine()!.Split(' '), 0);return input[iter++];}T Input<T>() where T : IParsable<T> => T.Parse(String(), null);int Int() => Input<int>();void Out(object? x, string? separator = null){separator ??= Environment.NewLine;if (x is System.Collections.IEnumerable obj and not string){var firstLine = true;foreach (var item in obj){if (!firstLine) sw.Write(separator);firstLine = false;sw.Write(item);}}else sw.Write(x);sw.WriteLine();}}