結果
問題 | No.2808 Concentration |
ユーザー | tenten |
提出日時 | 2024-07-17 13:21:01 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,668 bytes |
コンパイル時間 | 3,045 ms |
コンパイル使用メモリ | 81,740 KB |
実行使用メモリ | 117,300 KB |
最終ジャッジ日時 | 2024-07-17 13:22:13 |
合計ジャッジ時間 | 60,774 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | AC | 1,330 ms
89,800 KB |
testcase_04 | AC | 53 ms
36,812 KB |
testcase_05 | AC | 49 ms
36,976 KB |
testcase_06 | AC | 51 ms
36,764 KB |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | WA | - |
testcase_40 | WA | - |
testcase_41 | WA | - |
testcase_42 | WA | - |
testcase_43 | WA | - |
testcase_44 | WA | - |
testcase_45 | WA | - |
testcase_46 | WA | - |
testcase_47 | WA | - |
testcase_48 | WA | - |
testcase_49 | WA | - |
testcase_50 | WA | - |
testcase_51 | WA | - |
testcase_52 | WA | - |
testcase_53 | WA | - |
testcase_54 | WA | - |
testcase_55 | WA | - |
testcase_56 | AC | 52 ms
36,936 KB |
ソースコード
import java.io.*; import java.util.*; import java.util.function.*; import java.util.stream.*; public class Main { static long[] dp; static List<Speech> speeches = new ArrayList<>(); static int wake; static int sleep; static TreeMap<Integer, Integer> compress = new TreeMap<>(); public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); wake = sc.nextInt(); sleep = sc.nextInt(); for (int i = 0; i < n; i++) { Speech current = new Speech(sc.nextInt(), sc.nextInt(), sc.nextInt()); if (current.length() <= wake) { speeches.add(current); } } Collections.sort(speeches); for (int i = 0; i < speeches.size(); i++) { compress.put(speeches.get(i).end, i); } compress.put(Integer.MIN_VALUE, -1); dp = new long[speeches.size()]; Arrays.fill(dp, -1); System.out.println(dfw(speeches.size() - 1)); } static long dfw(int idx) { if (idx < 0) { return 0; } if (dp[idx] < 0) { dp[idx] = Math.max(dfw(idx - 1), dfw(compress.floorEntry(speeches.get(idx).start - sleep).getValue()) + speeches.get(idx).value); } return dp[idx]; } static class Speech implements Comparable<Speech> { int start; int end; int value; public Speech(int start, int end, int value) { this.start = start; this.end = end; this.value = value; } public int compareTo(Speech another) { return end - another.end; } public int length() { return end - start; } } } 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(); } } }