結果

問題 No.2730 Two Types Luggage
ユーザー 👑 hos.lyrichos.lyric
提出日時 2024-04-19 21:59:36
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 340 ms / 2,000 ms
コード長 2,111 bytes
コンパイル時間 2,222 ms
コンパイル使用メモリ 122,368 KB
実行使用メモリ 52,820 KB
最終ジャッジ日時 2024-04-19 21:59:50
合計ジャッジ時間 10,348 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 11 ms
5,376 KB
testcase_11 AC 266 ms
46,664 KB
testcase_12 AC 320 ms
49,980 KB
testcase_13 AC 224 ms
29,392 KB
testcase_14 AC 250 ms
46,640 KB
testcase_15 AC 77 ms
27,536 KB
testcase_16 AC 87 ms
11,236 KB
testcase_17 AC 310 ms
48,592 KB
testcase_18 AC 263 ms
52,588 KB
testcase_19 AC 23 ms
5,652 KB
testcase_20 AC 104 ms
20,376 KB
testcase_21 AC 244 ms
44,600 KB
testcase_22 AC 300 ms
49,624 KB
testcase_23 AC 26 ms
6,000 KB
testcase_24 AC 123 ms
22,600 KB
testcase_25 AC 233 ms
47,092 KB
testcase_26 AC 62 ms
11,356 KB
testcase_27 AC 211 ms
44,748 KB
testcase_28 AC 113 ms
21,496 KB
testcase_29 AC 271 ms
52,820 KB
testcase_30 AC 45 ms
22,540 KB
testcase_31 AC 183 ms
28,928 KB
testcase_32 AC 175 ms
26,192 KB
testcase_33 AC 322 ms
50,608 KB
testcase_34 AC 320 ms
50,480 KB
testcase_35 AC 333 ms
50,488 KB
testcase_36 AC 340 ms
50,480 KB
testcase_37 AC 318 ms
50,488 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.mathspecial, std.numeric, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }

string COLOR(string s = "") { return "\x1b[" ~ s ~ "m"; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }




void main() {
  try {
    for (; ; ) {
      const N = readInt;
      const M = readInt;
      const W = readLong;
      auto A = new long[N]; foreach (i; 0 .. N) A[i] = readLong;
      auto B = new long[M]; foreach (j; 0 .. M) B[j] = readLong;
      auto C = new long[M]; foreach (j; 0 .. M) C[j] = readLong;
      
      A.sort!"a > b";
      auto ASum = new long[N + 1];
      foreach (i; 0 .. N) ASum[i + 1] = ASum[i] + A[i];
      
      auto BSum = new long[1 << M];
      auto CSum = new long[1 << M];
      foreach (j; 0 .. M) {
        foreach (p; 0 .. 1 << j) {
          BSum[p | 1 << j] = BSum[p] + B[j];
          CSum[p | 1 << j] = CSum[p] + C[j];
        }
      }
      
      long ans;
      foreach (p; 0 .. 1 << M) if (BSum[p] <= W) {
        long score = CSum[p];
        score += ASum[min(W - BSum[p], N)];
        chmax(ans, score);
      }
      writeln(ans);
    }
  } catch (EOFException e) {
  }
}
0