hdu--1257--最少拦截系统(贪心)
#include<iostream> #include<vector> using namespace std; int main() { int n; while(cin>>n){ vector<int> vec; for(int i=0;i<n;++i){ int temp;cin>>temp; vec.push_back(temp); } vector<int> boom; int cut=0; for(auto it=vec.begin();it!=vec.end();++it){ int mark=0; auto iter=boom.begin(); for(int i=0;i<boom.size();++i,++iter){ if((*iter)>=(*it)){ (*iter)=(*it);mark=1;break; } } if(mark ==0){ cut++; boom.push_back((*it)); } } cout<<cut<<endl; } return 0; }