Start: Jul, 05, 2019 08:40:00
2019年度暑期短学期达标测试
End: Jul, 05, 2019 11:40:00
Time elapsed:
Time remaining:

Problem_ID: F
Result: Accepted
Time: 4ms
Memory: 1756kB
Author: CT12812081281
In contest: 1281

#include<iostream>
#include<algorithm>
#include<string.h>

using namespace std;

typedef struct Book{
    int len;
    int wid;
}Book;

int main(){
    int n,h,w,res,tmp,i;
    Book b[1000]={{0,0}};
    scanf("%d",&n);
    res=0;
    while(n--){
        scanf("%d%d",&h,&w);
        if(h>w){
            swap(h,w);
        }
        if(b[0].len==0){
            b[0].len=h;
            b[0].wid=w;
            res++;
        }else{
            for(i=0;b[i].len!=0;++i){
                if(h<=b[i].len&&w<=b[i].wid){
                    b[i].len=h;
                    b[i].wid=w;
                    break;
                }
            }
            if(b[i].len==0){
                b[i].len=h;
                b[i].wid=w;
                res++;
            }
        }


    }
    printf("%d\n",res);
    return 0;
}