UOJ Logo

NOI.AC

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#214177#2031. aThySecret00ms0kbC++111.5kb2024-11-15 22:08:472024-11-15 23:28:43

answer

#include <bits/stdc++.h>

using namespace std;

// #define int long long
// #define x first
// #define y second
#define File(a) freopen(a".in", "r", stdin), freopen(a".out", "w", stdout)

inline void debug() { cerr << '\n'; }
template<typename Type, typename... Other>
inline void debug(const Type& x, const Other&... y) { cerr << x << ' '; debug(y...); }
#define DEBUG(a...) cerr << "[" << #a << "] = ", debug(a);

typedef long long LL;
typedef pair<int, int> PII;

const int N = 30;
const int INF = 0x3f3f3f3f;

template<typename Type>
inline void read(Type &res)
{
    res = 0;
    int ch = getchar(), flag = 0;
    while (!isdigit(ch)) flag |= ch == '-', ch = getchar();
    while (isdigit(ch)) res = (res << 3) + (res << 1) + (ch ^ 48), ch = getchar();
    res = flag ? -res : res;
}
template<typename Type, typename... Other>
inline void read(Type &res, Other&... y) { read(res), read(y...); }

int n, k, ans;
int segs[N][2], tag[N];

signed main()
{
    read(n, k);
    for (int i = 0; i < n; i ++) read(segs[i][0], segs[i][1]);
    for (int state = 0; state < 1 << n; state ++)
    {
        if (__builtin_popcount(state) != k) continue;

        int res = 0;
        for (int i = 0; i < n; i ++)
            if (state >> i & 1)
                for (int j = segs[i][0]; j <= segs[i][1]; j ++) tag[j] ++;
        for (int i = 1; i <= n; i ++)
            if (tag[i]) res ++, tag[i] = 0;
        ans = max(ans, res);    
    }
    cout << ans << '\n';
    return 0;
}

Details

小提示:点击横条可展开更详细的信息

Test #1:

score: 0
Runtime Error

input:

20 8
941374267 958239792
636546050 949277063
30572593 458894768
377940690 585510776
595907552 909524...

output:


result:


Test #2:

score: 0
Runtime Error

input:

20 15
76365869 433406218
633171333 786737074
131600137 929106040
44288699 688307921
419471992 769278...

output:


result:


Test #3:

score: 0
Runtime Error

input:

20 2
358841118 908572644
771680732 777280263
232627681 399317312
146158799 355582975
95552785 629032...

output:


result:


Test #4:

score: 0
Runtime Error

input:

5000 49
383739070 641316367
609140743 773905546
333655225 869528584
456526030 666877251
488787058 91...

output:


result:


Test #5:

score: 0
Runtime Error

input:

5000 56
6389143 923791616
594084401 918014476
192256209 434682769
125655174 766893261
348541120 7426...

output:


result:


Test #6:

score: 0
Runtime Error

input:

5000 63
206266865 481555569
431544412 914639759
535710313 662467481
77260492 436949450
208295182 418...

output:


result:


Test #7:

score: 0
Runtime Error

input:

100000 95
31394575 31395303
35035434 35036166
64896609 64897277
10992021 10992677
17899328 17900254
...

output:


result:


Test #8:

score: 0
Runtime Error

input:

100000 83
233039267 233039367
916657359 916657459
864715109 864715209
936842396 936842496
562959930 ...

output:


result:


Test #9:

score: 0
Runtime Error

input:

100000 90
816642137 816642237
185449925 185450025
619425312 619425412
335954840 335954940
14523568 1...

output:


result:


Test #10:

score: 0
Runtime Error

input:

100000 85
932471751 932471851
591128329 591128429
632579047 632579147
902529780 902529880
377540930 ...

output:


result: