結果

問題 No.497 入れ子の箱
ユーザー 37zigen37zigen
提出日時 2017-03-24 23:38:34
言語 Java21
(openjdk 21)
結果
AC  
実行時間 253 ms / 5,000 ms
コード長 1,259 bytes
コンパイル時間 2,386 ms
コンパイル使用メモリ 75,948 KB
実行使用メモリ 59,920 KB
最終ジャッジ日時 2023-09-20 05:12:36
合計ジャッジ時間 11,149 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
56,008 KB
testcase_01 AC 130 ms
55,672 KB
testcase_02 AC 130 ms
56,160 KB
testcase_03 AC 242 ms
59,196 KB
testcase_04 AC 238 ms
59,232 KB
testcase_05 AC 238 ms
58,556 KB
testcase_06 AC 248 ms
59,176 KB
testcase_07 AC 248 ms
59,040 KB
testcase_08 AC 246 ms
59,052 KB
testcase_09 AC 240 ms
59,096 KB
testcase_10 AC 248 ms
58,560 KB
testcase_11 AC 244 ms
59,296 KB
testcase_12 AC 247 ms
59,108 KB
testcase_13 AC 246 ms
59,512 KB
testcase_14 AC 250 ms
59,124 KB
testcase_15 AC 253 ms
59,128 KB
testcase_16 AC 246 ms
58,752 KB
testcase_17 AC 249 ms
58,996 KB
testcase_18 AC 245 ms
59,920 KB
testcase_19 AC 249 ms
58,964 KB
testcase_20 AC 241 ms
58,652 KB
testcase_21 AC 243 ms
59,384 KB
testcase_22 AC 244 ms
59,036 KB
testcase_23 AC 218 ms
58,720 KB
testcase_24 AC 227 ms
58,952 KB
testcase_25 AC 129 ms
55,736 KB
testcase_26 AC 130 ms
55,684 KB
testcase_27 AC 236 ms
58,552 KB
testcase_28 AC 245 ms
59,260 KB
testcase_29 AC 242 ms
58,856 KB
testcase_30 AC 239 ms
58,872 KB
testcase_31 AC 237 ms
59,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;
import java.util.TreeSet;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[][] S = new int[N][3];
		for (int i = 0; i < N; ++i) {
			int[] a = new int[3];
			for (int j = 0; j < 3; ++j) {
				a[j] = sc.nextInt();
			}
			Arrays.sort(a);
			for (int j = 0; j < 3; ++j) {
				S[i][j] = a[j];
			}
		}

		Arrays.sort(S, new Comparator<int[]>() {
			@Override
			public int compare(int[] arg0, int[] arg1) {
				if (arg0[0] != arg1[0])
					return Integer.compare(arg0[0], arg1[0]);
				else if (arg0[1] != arg1[0])
					return Integer.compare(arg0[1], arg1[1]);
				else
					return Integer.compare(arg0[2], arg1[2]);
			}
		});

		int[] dp = new int[N];
		Arrays.fill(dp, 1);
		for (int i = 1; i < N; ++i) {
			for (int j = 0; j < i; ++j) {
				if (S[i][0] > S[j][0] && S[i][1] > S[j][1] && S[i][2] > S[j][2]) {
					dp[i] = Math.max(dp[i], dp[j] + 1);
				}
			}
		}
		int ans = 0;
		for (int i = 0; i < N; ++i) {
			ans = Math.max(ans, dp[i]);
		}
		System.out.println(ans);
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}
0