ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#187414 | #3368. 打怪闯关 | LuoxiDream | 100 | 18ms | 3268kb | C++ | 682b | 2023-10-02 09:25:24 | 2023-10-02 12:33:40 |
answer
#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
const int N = 1e5 + 10;
int n, ans;
long long h, sum;
struct get {
long long a, b;
} A[N];
priority_queue <long long, vector <long long>, less <long long> > pq;
void read() {
scanf("%d%lld", &n, &h);
sum = h;
for(int i = 1; i <= n; i++)
scanf("%lld%lld", &A[i].a, &A[i].b);
}
void work() {
for(int i = 1; i <= n; i++) {
pq.push(A[i].a);
sum -= A[i].a;
if(sum <= 0) {
while(!pq.empty() && sum <= 0) {
sum += pq.top();
pq.pop();
ans++;
}
}
sum += A[i].b;
}
printf("%d\n", ans);
}
int main() {
read();
work();
return 0;
}
详细
小提示:点击横条可展开更详细的信息
Test #1:
score: 10
Accepted
time: 0ms
memory: 1224kb
input:
2 5 5 3 3 4
output:
1
result:
ok single line: '1'
Test #2:
score: 10
Accepted
time: 0ms
memory: 1240kb
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: 1236kb
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: 1256kb
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: 1260kb
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: 1260kb
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: 1268kb
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: 1ms
memory: 1268kb
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: 1260kb
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: 17ms
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