結果

問題 No.2730 Two Types Luggage
ユーザー 👑 kakel-sankakel-san
提出日時 2024-04-29 21:42:58
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 644 ms / 2,000 ms
コード長 1,201 bytes
コンパイル時間 13,854 ms
コンパイル使用メモリ 167,880 KB
実行使用メモリ 330,200 KB
最終ジャッジ日時 2024-04-29 21:43:30
合計ジャッジ時間 30,692 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 50 ms
29,696 KB
testcase_01 AC 51 ms
29,948 KB
testcase_02 AC 50 ms
30,208 KB
testcase_03 AC 49 ms
30,080 KB
testcase_04 AC 58 ms
30,716 KB
testcase_05 AC 52 ms
30,464 KB
testcase_06 AC 48 ms
30,208 KB
testcase_07 AC 50 ms
30,208 KB
testcase_08 AC 49 ms
29,952 KB
testcase_09 AC 51 ms
30,720 KB
testcase_10 AC 65 ms
35,584 KB
testcase_11 AC 372 ms
130,432 KB
testcase_12 AC 611 ms
171,956 KB
testcase_13 AC 352 ms
113,920 KB
testcase_14 AC 395 ms
130,176 KB
testcase_15 AC 231 ms
56,572 KB
testcase_16 AC 174 ms
70,144 KB
testcase_17 AC 529 ms
168,556 KB
testcase_18 AC 497 ms
160,048 KB
testcase_19 AC 85 ms
41,856 KB
testcase_20 AC 201 ms
78,176 KB
testcase_21 AC 375 ms
125,696 KB
testcase_22 AC 530 ms
171,264 KB
testcase_23 AC 99 ms
43,136 KB
testcase_24 AC 229 ms
84,656 KB
testcase_25 AC 399 ms
131,452 KB
testcase_26 AC 144 ms
57,856 KB
testcase_27 AC 400 ms
125,952 KB
testcase_28 AC 211 ms
81,536 KB
testcase_29 AC 457 ms
160,888 KB
testcase_30 AC 195 ms
43,392 KB
testcase_31 AC 309 ms
112,768 KB
testcase_32 AC 272 ms
104,628 KB
testcase_33 AC 602 ms
173,696 KB
testcase_34 AC 616 ms
173,620 KB
testcase_35 AC 644 ms
174,080 KB
testcase_36 AC 620 ms
173,748 KB
testcase_37 AC 631 ms
330,200 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (141 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/

ソースコード

diff #

using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static int NN => int.Parse(ReadLine());
    static long[] NList => ReadLine().Split().Select(long.Parse).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var c = NList;
        var (n, m, w) = (c[0], (int)c[1], c[2]);
        var a = NList;
        var b = NList;
        c = NList;
        Array.Sort(a, (l, r) => r.CompareTo(l));
        var cum = new long[n + 1];
        for (var i = 0; i < n; ++i) cum[i + 1] = cum[i] + a[i];
        var bitmax = 1 << m;
        var ans = 0L;
        for (var p = 0; p < bitmax; ++p)
        {
            var tmp = p;
            var weight = 0L;
            var value = 0L;
            for (var i = 0; i < m; ++i)
            {
                if (tmp % 2 == 1)
                {
                    weight += b[i];
                    value += c[i];
                }
                tmp >>= 1;
            }
            if (weight <= w) ans = Math.Max(ans, value + cum[Math.Min(n, w - weight)]);
        }
        WriteLine(ans);
    }
}
0