結果

問題 No.497 入れ子の箱
ユーザー YamyukiYamyuki
提出日時 2017-03-24 23:08:46
言語 C90
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 942 bytes
コンパイル時間 837 ms
コンパイル使用メモリ 25,568 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-20 03:09:00
合計ジャッジ時間 2,034 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 WA -
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,376 KB
testcase_09 AC 6 ms
4,376 KB
testcase_10 AC 6 ms
4,376 KB
testcase_11 AC 6 ms
4,376 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 3 ms
4,380 KB
testcase_24 AC 3 ms
4,376 KB
testcase_25 AC 0 ms
4,380 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
権限があれば一括ダウンロードができます

ソースコード

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.s==b.s) return 0;
	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;
}

int main(int argc, char const *argv[]){
	int n,i,j,max=1,p;
	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++){
		p=b[i].n;
		for(j=0;j<i;j++){
			if(avail(b[i],b[j])==1) b[i].n=maximam(b[i].n,p+b[j].n);
		}
		max=maximam(b[i].n,max);
	}
	printf("%d\n",max);
	return 0;
}
0