srm 580 div1

要答辩,木有时间啊,练习了一下,依旧不给力,只能做出第一个,啥时候第二个能轻易做出来,也就说明我进步了吧~~~

1、离散所有点就可以了

 1 #include <iostream>
 2 #include <string>
 3 #include <vector>
 4 #include <cstdlib>
 5 #include <cmath>
 6 #include <map>
 7 #include <algorithm>
 8 #include <list>
 9 #include <ctime>
10 #include <set>
11 #include <string.h>
12 #include <queue>
13 using namespace std;
14 
15 class EelAndRabbit{
16 public:
17     int cal(vector <int>& l, vector <int>& t,int catchtime,vector<int>& judge){
18         int sz=l.size();
19         int ct=0;
20         for(int i=0;i<sz;i++){
21             if(catchtime>=t[i]&&catchtime<=(t[i]+l[i])&&judge[i]==0){
22                 ct++;
23                 judge[i]=1;
24             }
25         }
26         return ct;
27     }
28     int getmax(vector <int> l, vector <int> t){
29         int sz=l.size();
30         map<int,int> alltime;
31         for(int i=0;i<sz;i++){
32             alltime[t[i]]=1;
33             alltime[t[i]+l[i]]=1;
34         }
35         vector<int> rtime;
36         for(map<int,int>::iterator it=alltime.begin();alltime.end()!=it;it++){
37             int t=it->first;
38             rtime.push_back(t);
39         }
40         int rsz=rtime.size();
41         int res=0;
42         for(int i=0;i<rsz;i++){
43             for(int j=i+1;j<rsz;j++){
44                 vector<int> judge(sz,0);
45                 int f=cal(l,t,rtime[i],judge);
46                 int s=cal(l,t,rtime[j],judge);
47                 res=max(res,(f+s));
48             }
49         }
50         return res;
51     }
52 };

from kakamilan

posted on 2013-05-27 21:33  kakamilan  阅读(195)  评论(0编辑  收藏  举报

导航