結果

問題 No.2730 Two Types Luggage
ユーザー tentententen
提出日時 2024-04-22 10:25:17
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 2,522 bytes
コンパイル時間 2,939 ms
コンパイル使用メモリ 78,964 KB
実行使用メモリ 89,884 KB
最終ジャッジ日時 2024-04-22 10:25:43
合計ジャッジ時間 22,829 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
37,108 KB
testcase_01 AC 47 ms
37,116 KB
testcase_02 AC 49 ms
36,964 KB
testcase_03 AC 49 ms
37,092 KB
testcase_04 AC 54 ms
37,156 KB
testcase_05 AC 52 ms
36,992 KB
testcase_06 AC 57 ms
36,628 KB
testcase_07 AC 48 ms
37,080 KB
testcase_08 AC 51 ms
37,008 KB
testcase_09 AC 53 ms
36,664 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 762 ms
88,428 KB
testcase_18 AC 738 ms
87,532 KB
testcase_19 AC 226 ms
45,580 KB
testcase_20 AC 492 ms
54,736 KB
testcase_21 AC 716 ms
68,944 KB
testcase_22 AC 641 ms
89,460 KB
testcase_23 AC 301 ms
46,052 KB
testcase_24 AC 584 ms
56,120 KB
testcase_25 AC 597 ms
68,668 KB
testcase_26 AC 366 ms
51,656 KB
testcase_27 AC 716 ms
68,408 KB
testcase_28 AC 595 ms
55,764 KB
testcase_29 AC 709 ms
88,188 KB
testcase_30 AC 304 ms
46,648 KB
testcase_31 AC 602 ms
66,476 KB
testcase_32 AC 630 ms
64,944 KB
testcase_33 AC 797 ms
89,884 KB
testcase_34 AC 645 ms
89,344 KB
testcase_35 AC 760 ms
89,396 KB
testcase_36 AC 759 ms
89,500 KB
testcase_37 AC 787 ms
89,756 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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();
        }
    }
    
}
0