結果
問題 | No.497 入れ子の箱 |
ユーザー | zimpha |
提出日時 | 2017-03-25 18:20:45 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 127 ms / 5,000 ms |
コード長 | 2,761 bytes |
コンパイル時間 | 1,788 ms |
コンパイル使用メモリ | 78,548 KB |
実行使用メモリ | 52,924 KB |
最終ジャッジ日時 | 2024-07-06 06:05:49 |
合計ジャッジ時間 | 5,830 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 46 ms
50,448 KB |
testcase_01 | AC | 45 ms
50,156 KB |
testcase_02 | AC | 44 ms
50,612 KB |
testcase_03 | AC | 95 ms
52,844 KB |
testcase_04 | AC | 123 ms
52,908 KB |
testcase_05 | AC | 111 ms
52,228 KB |
testcase_06 | AC | 119 ms
52,924 KB |
testcase_07 | AC | 127 ms
52,724 KB |
testcase_08 | AC | 109 ms
52,536 KB |
testcase_09 | AC | 120 ms
52,848 KB |
testcase_10 | AC | 119 ms
52,388 KB |
testcase_11 | AC | 121 ms
52,324 KB |
testcase_12 | AC | 109 ms
52,876 KB |
testcase_13 | AC | 106 ms
52,452 KB |
testcase_14 | AC | 106 ms
52,652 KB |
testcase_15 | AC | 107 ms
52,472 KB |
testcase_16 | AC | 109 ms
52,276 KB |
testcase_17 | AC | 111 ms
52,832 KB |
testcase_18 | AC | 119 ms
52,276 KB |
testcase_19 | AC | 105 ms
52,344 KB |
testcase_20 | AC | 103 ms
52,436 KB |
testcase_21 | AC | 103 ms
52,644 KB |
testcase_22 | AC | 101 ms
52,452 KB |
testcase_23 | AC | 85 ms
52,140 KB |
testcase_24 | AC | 120 ms
52,492 KB |
testcase_25 | AC | 52 ms
50,384 KB |
testcase_26 | AC | 46 ms
50,116 KB |
testcase_27 | AC | 106 ms
52,680 KB |
testcase_28 | AC | 109 ms
52,720 KB |
testcase_29 | AC | 106 ms
52,544 KB |
testcase_30 | AC | 106 ms
52,160 KB |
testcase_31 | AC | 112 ms
52,588 KB |
ソースコード
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.io.BufferedReader; import java.util.Comparator; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * * @author Chiaki.Hoshinomori */ public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); PrintWriter out = new PrintWriter(outputStream); Task497 solver = new Task497(); solver.solve(1, in, out); out.close(); } static class Task497 { public void solve(int testNumber, InputReader in, PrintWriter out) { int n = in.nextInt(); int[][] box = new int[n][]; for (int i = 0; i < n; i++) { box[i] = new int[3]; for (int j = 0; j < 3; ++j) { box[i][j] = in.nextInt(); } Arrays.sort(box[i]); } Arrays.sort(box, new Comparator<int[]>() { public int compare(int[] o1, int[] o2) { if (o1[0] != o2[0]) return o1[0] - o2[0]; if (o1[1] != o2[1]) return o1[1] - o2[1]; return o1[2] - o2[2]; } }); int[] dp = new int[n]; int ret = 0; for (int i = 0; i < n; i++) { dp[i] = 1; for (int j = 0; j < i; j++) { if (box[j][0] < box[i][0] && box[j][1] < box[i][1] && box[j][2] < box[i][2]) { dp[i] = Math.max(dp[i], dp[j] + 1); } } ret = Math.max(ret, dp[i]); } out.println(ret); } } static class InputReader { public BufferedReader reader; public StringTokenizer tokenizer; public InputReader(InputStream stream) { reader = new BufferedReader(new InputStreamReader(stream), 32768); tokenizer = null; } public String next() { while (tokenizer == null || !tokenizer.hasMoreTokens()) { try { tokenizer = new StringTokenizer(reader.readLine()); } catch (IOException e) { throw new RuntimeException(e); } } return tokenizer.nextToken(); } public int nextInt() { return Integer.parseInt(next()); } } }