UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#214189#2031. aSTASISZHY30327ms9080kbC++111.2kb2024-11-15 22:20:462024-11-15 23:29:21

answer

// Problem: A. a
// Contest: undefined - NOIP2024训练赛 06
// URL: http://www.noi.ac/contest/1158/problem/2031
// Memory Limit: 256 MB
// Time Limit: 1000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include<bits/stdc++.h>
//#define int long long
#define fi first
#define se second
#define PII pair<int, int>

using namespace std;

const int N = 2e5 + 10, M = 1e6 + 10, mod = 1e9 + 7, INF = 0x3f3f3f3f;

int n, m, q, ans;
PII s[N], dp[N];
bool vis[N];

vector<int> e[N];

inline void solve(int st)
{
	int cnt = 0, res = 0;
	for(int i = 0; (1 << i) <= st; i ++)
	{
		if((st >> i) & 1) vis[i + 1] = true, cnt ++;
		else vis[i] = false;
	}
	if(cnt != n - m) return;
	int l = 1, r = 0;
	for(int i = 1; i <= n; i ++)
	{
		if(!vis[i]) continue;
		if(s[i].fi > r) res += (r - l + 1), l = s[i].fi, r = s[i].se;
		else r = max(s[i].se, r);
	}
	res += r - l + 1, ans = max(ans, res); 
}

signed main()
{
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n >> m;
	for(int i = 1; i <= n; i ++) {cin >> s[i].fi >> s[i].se; s[i].fi ++;}
	sort(s + 1, s + n + 1);
	for(int i = 1; i < (1 << n); i ++) solve(i);
	cout << ans << '\n';
	return 0;
}

详细

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

Test #1:

score: 10
Accepted
time: 74ms
memory: 9076kb

input:

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

output:

982023824

result:

ok single line: '982023824'

Test #2:

score: 10
Accepted
time: 75ms
memory: 9072kb

input:

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

output:

923804666

result:

ok single line: '923804666'

Test #3:

score: 10
Accepted
time: 69ms
memory: 9076kb

input:

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

output:

898648766

result:

ok single line: '898648766'

Test #4:

score: 0
Wrong Answer
time: 2ms
memory: 9076kb

input:

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

output:

0

result:

wrong answer 1st lines differ - expected: '999604831', found: '0'

Test #5:

score: 0
Wrong Answer
time: 2ms
memory: 9076kb

input:

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

output:

0

result:

wrong answer 1st lines differ - expected: '999844854', found: '0'

Test #6:

score: 0
Wrong Answer
time: 0ms
memory: 9080kb

input:

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

output:

0

result:

wrong answer 1st lines differ - expected: '999740177', found: '0'

Test #7:

score: 0
Wrong Answer
time: 26ms
memory: 9080kb

input:

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

output:

0

result:

wrong answer 1st lines differ - expected: '74878135', found: '0'

Test #8:

score: 0
Wrong Answer
time: 24ms
memory: 9076kb

input:

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

output:

0

result:

wrong answer 1st lines differ - expected: '9880370', found: '0'

Test #9:

score: 0
Wrong Answer
time: 27ms
memory: 9076kb

input:

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

output:

0

result:

wrong answer 1st lines differ - expected: '9879012', found: '0'

Test #10:

score: 0
Wrong Answer
time: 28ms
memory: 9076kb

input:

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

output:

0

result:

wrong answer 1st lines differ - expected: '9876663', found: '0'