「暑期训练」「Brute Force」 Far Relative’s Problem (CFR343D2B)

题意

之后补

分析

我哭了,强行增加自己的思考复杂度。。。明明一道尬写的题- -(往区间贪心方向想了
其实完全没必要,注意到只有366天,直接穷举判断即可。

代码

#include <bits/stdc++.h>
#define MP make_pair
#define PB push_back
#define fi first
#define se second
#define ZERO(x) memset((x), 0, sizeof(x))
#define ALL(x) (x).begin(),(x).end()
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i, a, b) for (int i = (a); i >= (b); --i)
#define QUICKIO                  
    ios::sync_with_stdio(false); 
    cin.tie(0);                  
    cout.tie(0);
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pi = pair<int, int>;
using pii = pair<int, pi>;

template<typename T>
T read()
{
    T tmp; cin>>tmp;
    return tmp;
}

int main()
{
    int n; cin>>n;
    int f[405],m[405];
    ZERO(f); ZERO(m);
    rep(i,1,n)
    {
        string tmp=read<string>();
        int tx,ty; cin>>tx>>ty;
        if(tmp=="M")
            rep(j,tx,ty) m[j]++;
        else rep(j,tx,ty) f[j]++;
    }
    int max_day=0;
    rep(i,0,366)
    {
        max_day=max(max_day,min(m[i],f[i]));
    }
    cout<<max_day*2<<endl;

    return 0;
}
如非注明,原创内容遵循GFDLv1.3发布;其中的代码遵循GPLv3发布。
原文地址:https://www.cnblogs.com/samhx/p/cfr343d2b.html