标签:clu multiset blank ++ rgb name space first namespace
http://www.pipioj.online/problem.php?id=1023
每次把当前的放在能排的当中最矮的一队里就ok
1 #define IO std::ios::sync_with_stdio(0); 2 #define bug(x) cout<<#x<<" is "<<x<<endl 3 #include <bits/stdc++.h> 4 #define iter ::iterator 5 using namespace std; 6 typedef long long ll; 7 typedef pair<int,int>P; 8 #define pb push_back 9 #define mk make_pair 10 #define se second 11 #define fi first 12 #define rs o*2+1 13 #define ls o*2 14 const ll mod=1e9+7; 15 const int N=2e5+5,M=3e6; 16 17 int n; 18 19 multiset<int>s; 20 21 int main(){ 22 while(~scanf("%d",&n)){ 23 s.clear(); 24 multiset<int>::iterator it; 25 int ans=1; 26 for(int i=1;i<=n;i++){ 27 int x; 28 scanf("%d",&x); 29 if(s.empty()){ 30 s.insert(x); 31 } 32 it=s.lower_bound(x); 33 if(it==s.end()){ 34 ans++; 35 s.insert(x); 36 } 37 else{ 38 s.erase(it); 39 s.insert(x); 40 } 41 } 42 printf("%d\n",ans); 43 } 44 45 }
标签:clu multiset blank ++ rgb name space first namespace
原文地址:https://www.cnblogs.com/ccsu-kid/p/14530646.html