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 }

时间: 2025-01-02 16:22:13

Codeforces Round #343 (Div. 2) B. Far Relative’s Problem的相关文章

Codeforces Round #343 (Div. 2) A. Far Relative’s Birthday Cake

水题 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> 1

Codeforces Round #343 (Div. 2) (C. Famil Door and Brackets(DP))

题目链接:点击打开链接 题意:给你一个长度为m的只含()的括号串s, 要求在s两端在加两个串p和q, 使得总长度为n,并且平衡, 平衡是指任意前缀串的(都不少于), 并且整个串的(和)一样多. 思路:我们不难想到这样一个DP, d[i][j]表示长度为i的串,(比)多j个(或者)比(多j个, 是等价的)的方案数.  那么转移很简单: if(j > 0) d[i][j] += d[i-1][j-1] ;    d[i][j] += d[i-1][j+1]. 然后为了满足那两个条件, 我们计算出s串

Codeforces Round #343 (Div. 2) D. Babaei and Birthday Cake(线段树+离散化优化DP)

题目链接:点击打开链接 题意:给出n个圆柱体的地面半径和高, 要求只能有一个直接放在桌子上, 其他的要放在他上面, 第i个能放在第j个上面的条件是:当且仅当第i个的体积大于第j个且j < i . 求能叠起来的最大体积. 思路:一看就是一个DP, 而且状态很容易表示, d[i]表示到第i个为止能得到的最大总体积.   转移到 max(d[j]) + a[i], (j < i && a[i] > a[j]).  但是n非常大, 显然要优化, 因为第二层循环所做的事情就是在i之

Codeforces Round #410 (Div. 2)C. Mike and gcd problem(数论)

传送门 Description Mike has a sequence A = [a1, a2, ..., an] of length n. He considers the sequence B = [b1, b2, ..., bn] beautiful if the gcd of all its elements is bigger than 1, i.e. . Mike wants to change his sequence in order to make it beautiful.

Codeforces Round #320 (Div. 1) [Bayan Thanks-Round] A A Problem about Polyline

题目中给出的函数具有周期性,总可以移动到第一个周期内,当然,a<b则无解. 假设移动后在上升的那段,则有a-2*x*n=b,注意限制条件x≥b,n是整数,则n≤(a-b)/(2*b).满足条件的x≥(a-b)/(2*n) 假设在下降的那段,2*x-(a-2*x*n)=b,n+1≤(a+b)/(2*b),x≥(a+b)/(2*(n+1)) 两者取最小值 #include<bits/stdc++.h> using namespace std; int main() { int a,b; sc

Codeforces Round #361 (Div. 2) E. Mike and Geometry Problem

题目链接:传送门 题目大意:给你n个区间,求任意k个区间交所包含点的数目之和. 题目思路:将n个区间都离散化掉,然后对于一个覆盖的区间,如果覆盖数cnt>=k,则数目应该加上 区间长度*(cnt与k的组合数) ans=ans+(len*C(cnt,k))%mod; #include <iostream> #include <cstdio> #include <cstdlib> #include <cmath> #include <algorith

Codeforces Round #279 (Div. 2) ABCD

Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems # Name     A Team Olympiad standard input/output 1 s, 256 MB  x2377 B Queue standard input/output 2 s, 256 MB  x1250 C Hacking Cypher standard input/output 1 s, 256 MB  x740 D Chocolate standard input/

【排序】【规律】Codeforces Round #254 (Div. 2) - D. Rooter&#39;s Song

D. DZY Loves FFT Source http://codeforces.com/contest/445/problem/D Description Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w?×?h, represented by a re

Codeforces Round #259 (Div. 2) 题解

A. Little Pony and Crystal Mine time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Twilight Sparkle once got a crystal from the Crystal Mine. A crystal of size n (n is odd; n?>?1) is an n?×?n