Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
193084 | zjx1015 | 友好城市 | C++ | 通过 | 100 | 1 MS | 352 KB | 595 | 2025-05-06 18:18:17 |
#include<bits/stdc++.h> using namespace std; int tttx,ttty,n; bool cmp(pair<int,int> a,pair<int,int> b){ return a.first==b.first?a.second>b.second:a.first<b.first; } int main(){ scanf("%d%d%d",&tttx,&ttty,&n); vector<pair<int,int>> v; int x,y; for(int i=0;i<n;i++){ scanf("%d%d",&x,&y); v.push_back({x,y}); } sort(v.begin(),v.end(),&cmp); vector<int> dp; for(auto num:v){ auto pos=upper_bound(dp.begin(),dp.end(),num.second); if(pos==dp.end())dp.push_back(num.second); else *pos=num.second; } printf("%d",dp.size()); return 0; }