36pts求助
查看原帖
36pts求助
391830
Locked_Fog楼主2022/1/26 10:17

RT

#include<bits/stdc++.h>
#define GO(from,to,var) for(int var=from;var<=to;var++)
#define GON(from,to,var) for(int var=from;var<to;var++)
#define GOGRA(EDGE,HEAD,var,u) for(int var = HEAD[u];var;var=EDGE[var].next)
#define COMP(__type,__member,__comp) [=](__type a1,__type a2)->bool{return a1.__member __comp a2.__member;}
using namespace std;
typedef int NUM;
const NUM maxn = 1e7;const NUM maxm = 1e7;
void Read();void Solve();
inline NUM fr(){
    NUM x = 0, dis = 1;
    char ch = getchar();
    while(ch<'0'||ch>'9'){
        if(ch == '-')dis = -1;
        ch = getchar();}
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch = getchar();}
    return x*dis;
}
struct LOG{int length,width;}a[maxn],f[maxn];
bool comp(LOG a1,LOG a2){
    if(a1.length == a2.length)return a1.width>a2.width;
    else return a1.length>a2.length;
}
int n;
inline void Dp(){
    int cnt=1;
    f[1]=a[1];
    GO(2,n,i){
        if(a[i].length>f[cnt].length || a[i].width>f[cnt].width)f[++cnt]=a[i];
        else{
            int num = lower_bound(f+1,f+cnt+1,a[i],comp)-f;
            f[num]=a[i];
        }
    }
    printf("%d",cnt);
}
void Read(){
    n=fr();
    GO(1,n,i){
        int l=fr(),w=fr();
        a[i]={l,w};
    }
}
void Solve(){
    sort(a+1,a+n+1,comp);
    Dp();
}
int main(){
    Read();
    Solve();
    return 0;
}

到底哪里错了?只A了前4个点

2022/1/26 10:17
加载中...