栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

zoj 2283 Challenge of Wisdom

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

zoj 2283 Challenge of Wisdom

#include <cstdio>#include <algorithm>using namespace std;const int maxn=1e6+5;int n,m,p;struct pnt{        int x,y;        pnt(){x=y=0;}        pnt(int x,int y){this->x=x;this->y=y;}        bool operator < (pnt p2)const {return x!=p2.x?x<p2.x:y<p2.y;}        bool operator > (pnt p2)const {return x!=p2.x?x>p2.x:y>p2.y;}        pnt operator = (const pnt p2){x=p2.x;y=p2.y;return *this;}};pnt pt[maxn];int dp[maxn],len;void replace(int x){        int l=0,r=len;        while(r>l){     int m=(l+r)>>1;     if(dp[m]>x){  l=m+1;     }     else  {  r=m;     }        }        if(dp[l]<x&&l<len)dp[l]=x;}int main(){        while(scanf("%d%d%d",&n,&m,&p)==3){     len=0;     for(int i=0;i<p;i++){  scanf("%d%d",&pt[i].x,&pt[i].y);     }     sort(pt,pt+p);     if(p>0)dp[len++]=pt[0].y;     for(int i=1;i<p;i++){  if(dp[len-1]>pt[i].y){          dp[len++]=pt[i].y;  }  else {          replace(pt[i].y);  }     }     printf("%dn",len);        }        return 0;}
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/380627.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号