ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#215232 | #2639. 省钱 | a_sad_soul | 0 | 140ms | 2500kb | C++11 | 628b | 2024-11-27 19:15:55 | 2024-11-27 23:36:26 |
answer
#include<bits/stdc++.h>
using namespace std;
int n;
typedef long long ll;
ll C,k;
bool vis[5000505];
struct node{
ll w,q;
}a[5000505];
int main(){
scanf("%d%d%lld",&n,&k,&C);
for(int i=1;i<=n;++i){
scanf("%lld%lld",&a[i].w,&a[i].q);
}
sort(a+1,a+1+n,[](node a,node b){return a.w<b.w;});
int cnt=0,ans=0,tot=0;
ll sum=0;
priority_queue<ll,vector<ll>,greater<ll>>q;
for(int i=1;i<=n;++i){
if(sum+a[i].q<=C){
sum+=a[i].q;++tot;++cnt;
q.push(a[i].w-a[i].q);
}
if(tot>k){
sum+=q.top();q.pop();--tot;
}
ans=max(ans,cnt);
if(sum>C)break;
}
cout<<ans<<endl;
return 0;
}
详细
小提示:点击横条可展开更详细的信息
Test #1:
score: 0
Wrong Answer
time: 14ms
memory: 2180kb
input:
50000 30828 852557364841 682084050 257603011 870868024 517458094 732267860 201407488 777566656 55879...
output:
13009
result:
wrong answer 1st lines differ - expected: '17903', found: '13009'
Test #2:
score: 0
Wrong Answer
time: 16ms
memory: 2180kb
input:
50000 10508 8982273367520 34111224 12372852 549875017 525549262 357107918 219952140 644308048 222008...
output:
36038
result:
wrong answer 1st lines differ - expected: '37621', found: '36038'
Test #3:
score: 0
Wrong Answer
time: 15ms
memory: 2176kb
input:
50000 23114 535861686266 359271294 298114231 605400720 491693949 755566780 539381575 155586610 92962...
output:
10429
result:
wrong answer 1st lines differ - expected: '14723', found: '10429'
Test #4:
score: 0
Wrong Answer
time: 15ms
memory: 2176kb
input:
50000 13490 4616703243118 286358449 133228996 162995754 17235506 661390160 561824344 282751480 15433...
output:
28072
result:
wrong answer 1st lines differ - expected: '30961', found: '28072'
Test #5:
score: 0
Wrong Answer
time: 11ms
memory: 2240kb
input:
50000 26352 8630976119100 70133466 32927792 90392510 89764542 307782646 75889114 123168574 66039130 ...
output:
40337
result:
wrong answer 1st lines differ - expected: '42944', found: '40337'
Test #6:
score: 0
Wrong Answer
time: 15ms
memory: 2168kb
input:
50000 11800 213255455323 405512104 311547645 122797690 35257030 782246460 533338866 416860264 504733...
output:
6609
result:
wrong answer 1st lines differ - expected: '9869', found: '6609'
Test #7:
score: 0
Wrong Answer
time: 15ms
memory: 2240kb
input:
50000 19734 4267681411347 732638120 327229436 361949068 274173372 539440696 285784669 94445920 84513...
output:
28536
result:
wrong answer 1st lines differ - expected: '32498', found: '28536'
Test #8:
score: 0
Wrong Answer
time: 14ms
memory: 2052kb
input:
50000 254 18445304121 375481124 36148026 388507104 183081259 261838134 179691990 485282800 209534680...
output:
1498
result:
wrong answer 1st lines differ - expected: '1564', found: '1498'
Test #9:
score: 0
Wrong Answer
time: 10ms
memory: 2108kb
input:
50000 3260 4076050769242 210627773 8756794 68253913 5333287 812306900 176444281 561388618 94960450 6...
output:
22465
result:
wrong answer 1st lines differ - expected: '23173', found: '22465'
Test #10:
score: 0
Wrong Answer
time: 15ms
memory: 2500kb
input:
50000 44485 12129791734731 590854222 262410600 992399148 641692708 219274382 56485932 730651726 4088...
output:
49133
result:
wrong answer 1st lines differ - expected: '49537', found: '49133'