Codeforces Round #343 (Div. 2) B. Far Relative’s Problem

题意:n个人,在规定时间范围内,找到最多有多少对男女能一起出面。

思路:ans=max(2*min(一天中有多少个人能出面))

 1 #include<iostream>
 2 #include<string>
 3 #include<algorithm>
 4 #include<cstdlib>
 5 #include<cstdio>
 6 #include<set>
 7 #include<map>
 8 #include<vector>
 9 #include<cstring>
10 #include<stack>
11 #include<cmath>
12 #include<queue>
13 #define clc(a,b) memset(a,b,sizeof(a))
14 #include <bits/stdc++.h>
15 using namespace std;
16 #define LL long long
17 
18 
19 int main()
20 {
21     int n;
22     int p[2][370];
23     scanf("%d",&n);
24     clc(p,0);
25     for(int i=1; i<=n; i++)
26     {
27         char c;
28         int l,r;
29         getchar();
30         scanf("%c%d%d",&c,&l,&r);
31         if(c=='M')
32         {
33             for(int j=l; j<=r; j++)
34                 p[0][j]++;
35         }
36         else
37         {
38             for(int j=l; j<=r; j++)
39                 p[1][j]++;
40         }
41     }
42     int ans=0;
43     for(int i=1; i<=366; i++)
44         ans=max(ans,2*min(p[0][i],p[1][i]));
45     cout<<ans<<endl;
46     return 0;
47 }
View Code
原文地址:https://www.cnblogs.com/ITUPC/p/5207733.html