結果

問題 No.497 入れ子の箱
ユーザー YamyukiYamyuki
提出日時 2017-03-24 23:15:11
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 11 ms / 5,000 ms
コード長 915 bytes
コンパイル時間 500 ms
コンパイル使用メモリ 25,504 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-20 03:38:06
合計ジャッジ時間 2,206 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 5 ms
4,376 KB
testcase_04 AC 6 ms
4,376 KB
testcase_05 AC 5 ms
4,380 KB
testcase_06 AC 5 ms
4,380 KB
testcase_07 AC 6 ms
4,376 KB
testcase_08 AC 6 ms
4,380 KB
testcase_09 AC 6 ms
4,380 KB
testcase_10 AC 6 ms
4,376 KB
testcase_11 AC 6 ms
4,376 KB
testcase_12 AC 11 ms
4,380 KB
testcase_13 AC 11 ms
4,376 KB
testcase_14 AC 11 ms
4,376 KB
testcase_15 AC 11 ms
4,380 KB
testcase_16 AC 11 ms
4,376 KB
testcase_17 AC 11 ms
4,380 KB
testcase_18 AC 5 ms
4,380 KB
testcase_19 AC 6 ms
4,380 KB
testcase_20 AC 6 ms
4,380 KB
testcase_21 AC 5 ms
4,380 KB
testcase_22 AC 6 ms
4,376 KB
testcase_23 AC 3 ms
4,376 KB
testcase_24 AC 4 ms
4,380 KB
testcase_25 AC 0 ms
4,380 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 9 ms
4,380 KB
testcase_28 AC 8 ms
4,376 KB
testcase_29 AC 8 ms
4,380 KB
testcase_30 AC 5 ms
4,380 KB
testcase_31 AC 4 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>
#include<stdlib.h>
#define maximam(a,b) ((a)>(b))?(a):(b)
typedef struct{
	long x,y,z;
	long s;
	int n;
} box;

int cmp(const void *a, const void *b){
	return ((box *)a)->s-((box *)b)->s;
}

int avail(box a, box b){
	if(a.x>b.x && a.y>b.y && a.z>b.z) return 1;
	if(a.x>b.x && a.y>b.z && a.z>b.y) return 1;
	if(a.x>b.y && a.y>b.x && a.z>b.z) return 1;
	if(a.x>b.y && a.y>b.z && a.z>b.x) return 1;
	if(a.x>b.z && a.y>b.x && a.z>b.y) return 1;
	if(a.x>b.z && a.y>b.y && a.z>b.x) return 1;
	return 0;
}

int main(int argc, char const *argv[]){
	int n,i,j,max=1;
	box b[1000];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%ld %ld %ld",&b[i].x,&b[i].y,&b[i].z);
		b[i].s=b[i].x+b[i].y+b[i].z;
		b[i].n=1;
	}
	qsort(b,n,sizeof(box),cmp);
	for(i=0;i<n;i++){
		for(j=0;j<i;j++){
			if(avail(b[i],b[j])==1) b[i].n=maximam(b[i].n,1+b[j].n);
		}
		max=maximam(b[i].n,max);
	}
	printf("%d\n",max);
	return 0;
}
0