結果

問題 No.497 入れ子の箱
ユーザー 37zigen37zigen
提出日時 2017-03-24 23:36:58
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,259 bytes
コンパイル時間 4,483 ms
コンパイル使用メモリ 75,724 KB
実行使用メモリ 61,808 KB
最終ジャッジ日時 2023-09-20 04:36:12
合計ジャッジ時間 13,647 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
39,360 KB
testcase_01 AC 131 ms
39,260 KB
testcase_02 AC 129 ms
52,060 KB
testcase_03 AC 233 ms
42,940 KB
testcase_04 AC 241 ms
43,192 KB
testcase_05 AC 243 ms
42,764 KB
testcase_06 AC 240 ms
43,176 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 AC 221 ms
43,628 KB
testcase_24 AC 228 ms
43,088 KB
testcase_25 AC 124 ms
39,652 KB
testcase_26 AC 124 ms
39,408 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 234 ms
42,828 KB
testcase_31 AC 230 ms
42,348 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][1] && 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