「暑期訓練」「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;
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章