ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#187634 | #3368. 打怪闯关 | 213555 | 100 | 11ms | 2968kb | C++11 | 815b | 2023-10-02 11:39:22 | 2023-10-02 12:50:44 |
answer
#include<bits/stdc++.h>
using namespace std;
long long read(){
long long x=0,f=1;
char ch=getchar();
while(ch<'0'||ch>'9'){
if(ch=='-')
f=-1;
ch=getchar();
}
while(ch>='0'&&ch<='9'){
x=(x<<1)+(x<<3)+(ch^48);
ch=getchar();
}
return x*f;
}
void write(long long x){
if(x<0){
putchar('-');
x=-x;
}
if(x>9)write(x/10);
putchar(x%10+'0');
}
long long n,h,a[100005],b[100005],maxn=-1,k=0,l=0;
priority_queue<int>q;
int main(){
//freopen("1.txt","r",stdin);
n=read(),h=read();
for(int i=1;i<=n;i++){
a[i]=read();
b[i]=read();
}
for(int i=1;i<=n;i++){
k+=a[i];
q.push(a[i]);
if(k>=h){
k-=q.top();
q.pop();
l++;
}
k-=b[i];
}
cout<<l;
return 0;
}
详细
小提示:点击横条可展开更详细的信息
Test #1:
score: 10
Accepted
time: 0ms
memory: 1200kb
input:
2 5 5 3 3 4
output:
1
result:
ok single line: '1'
Test #2:
score: 10
Accepted
time: 0ms
memory: 1216kb
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: 1220kb
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: 1240kb
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: 0ms
memory: 1236kb
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: 1236kb
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: 1248kb
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: 1244kb
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: 1240kb
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: 11ms
memory: 2968kb
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