結果
問題 | No.2730 Two Types Luggage |
ユーザー | tenten |
提出日時 | 2024-04-22 10:25:17 |
言語 | Java21 (openjdk 21) |
結果 |
RE
|
実行時間 | - |
コード長 | 2,522 bytes |
コンパイル時間 | 2,452 ms |
コンパイル使用メモリ | 79,676 KB |
実行使用メモリ | 100,940 KB |
最終ジャッジ日時 | 2024-10-14 09:40:24 |
合計ジャッジ時間 | 23,220 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 56 ms
50,356 KB |
testcase_01 | AC | 57 ms
50,432 KB |
testcase_02 | AC | 58 ms
50,352 KB |
testcase_03 | AC | 58 ms
50,576 KB |
testcase_04 | AC | 61 ms
50,244 KB |
testcase_05 | AC | 60 ms
50,476 KB |
testcase_06 | AC | 56 ms
50,572 KB |
testcase_07 | AC | 56 ms
50,240 KB |
testcase_08 | AC | 56 ms
50,440 KB |
testcase_09 | AC | 60 ms
50,132 KB |
testcase_10 | RE | - |
testcase_11 | RE | - |
testcase_12 | RE | - |
testcase_13 | RE | - |
testcase_14 | RE | - |
testcase_15 | RE | - |
testcase_16 | RE | - |
testcase_17 | AC | 852 ms
99,696 KB |
testcase_18 | AC | 737 ms
98,800 KB |
testcase_19 | AC | 255 ms
56,548 KB |
testcase_20 | AC | 523 ms
64,824 KB |
testcase_21 | AC | 770 ms
79,832 KB |
testcase_22 | AC | 757 ms
100,476 KB |
testcase_23 | AC | 308 ms
56,808 KB |
testcase_24 | AC | 580 ms
66,192 KB |
testcase_25 | AC | 644 ms
82,048 KB |
testcase_26 | AC | 411 ms
63,668 KB |
testcase_27 | AC | 716 ms
80,112 KB |
testcase_28 | AC | 577 ms
67,060 KB |
testcase_29 | AC | 734 ms
98,464 KB |
testcase_30 | AC | 314 ms
57,008 KB |
testcase_31 | AC | 665 ms
79,924 KB |
testcase_32 | AC | 622 ms
75,856 KB |
testcase_33 | AC | 823 ms
100,820 KB |
testcase_34 | AC | 675 ms
100,824 KB |
testcase_35 | AC | 781 ms
100,940 KB |
testcase_36 | AC | 813 ms
100,700 KB |
testcase_37 | AC | 844 ms
100,816 KB |
ソースコード
import java.io.*; import java.util.*; import java.util.function.*; import java.util.stream.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); int m = sc.nextInt(); long w = sc.nextLong(); int[] values = new int[n]; for (int i = 0; i < n; i++) { values[i] = sc.nextInt(); } Arrays.sort(values); int[] weight = new int[m]; for (int i = 0; i < m; i++) { weight[i] = sc.nextInt(); } TreeMap<Long, Long> worth = new TreeMap<>(); worth.put(0L, 0L); for (int i = 0; i < m; i++) { int x = sc.nextInt(); Long key = Long.MAX_VALUE; while ((key = worth.lowerKey(key)) != null) { if (worth.floorEntry(key + weight[i]).getValue() >= worth.get(key) + x) { continue; } worth.put(key + weight[i], worth.get(key) + x); Long current = key + weight[i]; while ((current = worth.higherKey(current)) != null) { if (worth.get(current) <= worth.get(key) + x) { worth.remove(current); } else { break; } } } } long ans = worth.floorEntry(w).getValue(); long current = 0; for (int i = 1; i <= n; i++) { current += values[n - i]; ans = Math.max(ans, worth.floorEntry(w - i).getValue() + current); } System.out.println(ans); } } class Scanner { BufferedReader br; StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() { try { br = new BufferedReader(new InputStreamReader(System.in)); } catch (Exception e) { } } public int nextInt() { return Integer.parseInt(next()); } public long nextLong() { return Long.parseLong(next()); } public double nextDouble() { return Double.parseDouble(next()); } public String next() { try { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } } catch (Exception e) { e.printStackTrace(); } finally { return st.nextToken(); } } }