結果
| 問題 |
No.497 入れ子の箱
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-03-24 23:15:11 |
| 言語 | C90 (gcc 12.3.0) |
| 結果 |
AC
|
| 実行時間 | 7 ms / 5,000 ms |
| コード長 | 915 bytes |
| コンパイル時間 | 127 ms |
| コンパイル使用メモリ | 22,656 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-05 23:56:36 |
| 合計ジャッジ時間 | 1,017 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 |
コンパイルメッセージ
main.c: In function ‘main’:
main.c:27:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
27 | scanf("%d",&n);
| ^~~~~~~~~~~~~~
main.c:29:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
29 | scanf("%ld %ld %ld",&b[i].x,&b[i].y,&b[i].z);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#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;
}