[Codeforces Round #165 (Div. 2)]D. Greenhouse Effect

地址:http://codeforces.com/contest/270/problem/D

这题看过别人代码,理解了好久

本来觉得这题和USACO里的三值的排序是一样的,但是USACO里通不过......看来还得想

 1 #include <iostream>
 2 #include <algorithm>
 3 using namespace std;
 4 
 5 int n,m,s[5001],p[5001];
 6 double x;
 7 
 8 int main()
 9 {
10     ios::sync_with_stdio(false);
11     int j;
12     cin>>n>>m;
13     for(int i=0;i<n;i++) cin>>s[i]>>x;
14     m=0;
15     for(int i=0;i<n;i++)
16     {
17         j=(int)(upper_bound(p,p+m,s[i])-p);
18         if(j==m) p[m++]=s[i];
19         else p[j]=s[i];
20     }
21     cout<<n-m<<endl;
22     return 0;
23 }

 

posted @ 2013-02-10 21:19  tjsuhst  阅读(179)  评论(0编辑  收藏  举报