UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#187706#3368. 打怪闯关heyuzhen10023ms3268kbC++386b2023-10-02 12:11:592023-10-02 12:57:00

answer

#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll n,m,a[100005],b[100005],ans;
priority_queue<ll> q;
int main(){
	scanf("%lld%lld",&n,&m);
	for(ll i = 1;i <= n;i++)
		scanf("%lld%lld",&a[i],&b[i]);
	for(ll i = 1;i <= n;i++){
		q.push(a[i]);
		while(m <= a[i]){
			m += q.top(),ans++;
			q.pop();
		}m = m - a[i] + b[i];
	}cout << ans;
	return 0;
}

详细

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

Test #1:

score: 10
Accepted
time: 1ms
memory: 1248kb

input:

2 5
5 3
3 4

output:

1

result:

ok single line: '1'

Test #2:

score: 10
Accepted
time: 0ms
memory: 1256kb

input:

8 26
38 3
28 15
16 3
44 29
27 16
30 26
20 11
33 19

output:

3

result:

ok single line: '3'

Test #3:

score: 10
Accepted
time: 0ms
memory: 1260kb

input:

10 26
22 10
29 25
18 13
43 10
37 4
23 11
16 6
46 35
39 10
26 20

output:

4

result:

ok single line: '4'

Test #4:

score: 10
Accepted
time: 0ms
memory: 1284kb

input:

991 3081
2149 0
9730 0
1890 0
6659 0
9526 0
2240 0
3513 0
720 0
7828 0
7676 0
9905 0
9583 0
9400 0
2...

output:

970

result:

ok single line: '970'

Test #5:

score: 10
Accepted
time: 1ms
memory: 1284kb

input:

1000 9221
6895 0
9009 0
2330 0
6982 0
2952 0
2853 0
7734 0
7242 0
9937 0
4914 0
8390 0
6394 0
2513 0...

output:

950

result:

ok single line: '950'

Test #6:

score: 10
Accepted
time: 0ms
memory: 1284kb

input:

995 770
7448 0
5184 0
8577 0
8793 0
970 0
362 0
1955 0
660 0
4750 0
2151 0
4171 0
3206 0
5627 0
3856...

output:

985

result:

ok single line: '985'

Test #7:

score: 10
Accepted
time: 0ms
memory: 1296kb

input:

993 5422
4898 454
9872 3356
9017 379
1820 197
8988 914
575 1188
6176 2226
9886 1576
1051 3190
9389 2...

output:

444

result:

ok single line: '444'

Test #8:

score: 10
Accepted
time: 0ms
memory: 1296kb

input:

991 1563
5451 2619
3343 1298
9457 651
3631 868
9710 1991
3893 1406
4590 478
9112 621
3159 663
6627 7...

output:

477

result:

ok single line: '477'

Test #9:

score: 10
Accepted
time: 0ms
memory: 1284kb

input:

993 407
197 784
8030 2340
2600 2629
6658 173
7729 3069
1402 3040
8811 1501
2530 1310
7972 1275
6568 ...

output:

483

result:

ok single line: '483'

Test #10:

score: 10
Accepted
time: 21ms
memory: 3268kb

input:

99436 6518
4071 628
3967 598
9513 2785
2337 534
3076 1048
5703 458
5984 489
3387 542
4054 4140
5 963...

output:

46265

result:

ok single line: '46265'

Extra Test:

score: 0
Extra Test Passed