結果
問題 | No.497 入れ子の箱 |
ユーザー |
![]() |
提出日時 | 2020-12-24 16:41:45 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 257 ms / 5,000 ms |
コード長 | 1,344 bytes |
コンパイル時間 | 1,992 ms |
コンパイル使用メモリ | 77,368 KB |
実行使用メモリ | 57,524 KB |
最終ジャッジ日時 | 2024-09-21 16:58:44 |
合計ジャッジ時間 | 10,329 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
ソースコード
import java.util.*;public class Main {public static void main(String[] args) {Scanner sc = new Scanner(System.in);int n = sc.nextInt();Box[] boxes = new Box[n];for (int i = 0; i < n; i++) {boxes[i] = new Box(sc.nextInt(), sc.nextInt(), sc.nextInt());}Arrays.sort(boxes);int[] counts = new int[n];int max = 0;for (int i = 0; i < n; i++) {for (int j = 0; j < i; j++) {if (boxes[j].bigger(boxes[i])) {counts[i] = Math.max(counts[i], counts[j] + 1);max = Math.max(max, counts[i]);}}}System.out.println(max + 1);}static class Box implements Comparable<Box> {int[] arr = new int[3];public Box(int x, int y, int z) {arr[0] = x;arr[1] = y;arr[2] = z;Arrays.sort(arr);}public int compareTo(Box another) {return arr[0] - another.arr[0];}public boolean bigger(Box another) {for (int i = 0; i < 3; i++) {if (arr[i] >= another.arr[i]) {return false;}}return true;}}}