結果

問題 No.497 入れ子の箱
ユーザー fal_rndfal_rnd
提出日時 2017-03-24 23:07:44
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 979 bytes
コンパイル時間 4,457 ms
コンパイル使用メモリ 74,228 KB
実行使用メモリ 59,704 KB
最終ジャッジ日時 2023-09-20 03:05:19
合計ジャッジ時間 11,791 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
55,972 KB
testcase_01 AC 124 ms
56,240 KB
testcase_02 AC 124 ms
55,900 KB
testcase_03 AC 199 ms
58,404 KB
testcase_04 AC 214 ms
59,028 KB
testcase_05 AC 214 ms
59,000 KB
testcase_06 AC 212 ms
59,012 KB
testcase_07 AC 219 ms
59,108 KB
testcase_08 AC 216 ms
59,148 KB
testcase_09 AC 216 ms
59,156 KB
testcase_10 AC 215 ms
58,560 KB
testcase_11 AC 215 ms
59,088 KB
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 202 ms
58,848 KB
testcase_24 AC 212 ms
59,208 KB
testcase_25 AC 126 ms
56,016 KB
testcase_26 AC 128 ms
55,900 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 217 ms
58,832 KB
testcase_31 AC 217 ms
59,064 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	static final Scanner s = new Scanner(System.in);
	public static void main(String args[]){
		Box[] boxes = new Box[s.nextInt()];
		for(int i=0;i<boxes.length;i++)
			boxes[i]=new Box(s.nextInt(), s.nextInt(), s.nextInt());

		Arrays.sort(boxes);
		//Arrays.stream(boxes).forEach(System.out::println);

		int nest=1;
		Box inner = boxes[0];
		for(int i=1;i<boxes.length;i++) {
			if(boxes[i].isRearryLargerThan(inner)) {
				inner=(boxes[i]);
				nest++;
			}
		}
		System.out.println(nest);
	}
}
class Box implements Comparable<Box>{
	int v[];
	public Box(int x,int y,int z) {
		v = new int[]{x,y,z};
		Arrays.sort(v);
	}
	public boolean isRearryLargerThan(Box b) {
		return v[0]>b.v[0]&&v[1]>b.v[1]&&v[2]>b.v[2];
	}
	@Override
	public int compareTo(Box o) {
		if(v[0]-o.v[0]!=0) return v[0]-o.v[0];
		if(v[1]-o.v[1]!=0) return v[1]-o.v[1];
		return v[2]-o.v[2];
	}
	@Override
	public String toString() {
		return Arrays.toString(v);
	}
}
0