UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#215116#2441. 物品a_sad_soul602227ms10620kbC++11941b2024-11-26 19:28:032024-11-26 23:01:56

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll C;
int n;
const int MAXN = 5e5+10;
int a[MAXN],w[MAXN];
vector<int>ans;
bool calc(int m){
    vector<int>q;
    for(int i=1;i<=n;++i)if(a[i]>=m)q.push_back(i);
    sort(q.begin(),q.end(),[&](int x,int y){return w[x]<w[y];});
    ll now=C,cnt=0;
    vector<int>k;
    for(int x:q)if(w[x]<=now)now-=w[x],++cnt,k.push_back(x);
    if(cnt>=m){ans.clear();for(int x:k)ans.push_back(x);}
    return cnt>=m;
}
int solve(){
    int l=0,r=n,ans=0;
    while(l<=r){
        int mid=(l+r)>>1;
        if(calc(mid))ans=mid,l=mid+1;
        else r=mid-1;
    }
    return ans;
}
int main(){
    scanf("%d%lld",&n,&C);
    for(int i=1;i<=n;++i)scanf("%d%d",&a[i],&w[i]);
    calc(solve());
    int Cnt=0;
    for(int x:ans)Cnt+=a[x]>=ans.size();
    cout<<Cnt<<endl;
    printf("%d\n",ans.size());
    for(int v:ans)printf("%d ",v);
    return 0;
}

详细

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

Test #1:

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

input:

18 1024
8 3
8 1
16 9
17 6
2 5
12 3
1 7
7 9
17 1
14 3
2 7
17 5
2 3
2 5
2 10
8 3
2 3
17 5

output:

7
10
2 9 1 6 10 16 12 18 4 3 

result:

wrong answer Wrong answer!

Test #2:

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

input:

20 79841
15 4337
9 6289
7 9927
12 1468
7 9390
12 9228
7 5646
8 3438
3 1614
3 7048
10 8840
15 2349
16...

output:

10
10
4 12 14 1 13 20 19 11 6 17 

result:

points 1.0 Correct

Test #3:

score: 10
Accepted
time: 2ms
memory: 1328kb

input:

1888 987654
1082 243
1341 309
1524 959
324 593
894 952
1428 587
1367 91
1669 683
616 866
958 791
172...

output:

949
949
909 1341 231 1259 1327 335 873 1671 892 1070 1872 452 339 501 258 1027 793 1067 1740 665 851...

result:

points 1.0 Correct

Test #4:

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

input:

1999 12000000
1112 2799
524 6890
686 6713
1803 4478
940 4341
1391 8972
953 592
454 7711
524 8224
127...

output:

978
978
53 174 195 1092 1807 517 789 1823 1014 991 423 1060 1800 350 769 1484 1428 1739 704 795 492 ...

result:

points 1.0 Correct

Test #5:

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

input:

2000 9788123
296 3976
154 3441
78 9146
1443 6444
1799 2843
1482 6843
1526 3159
1956 9324
1442 1001
5...

output:

997
997
725 67 1669 1837 1146 694 38 223 1735 1651 1228 358 1005 811 1395 1180 1094 1150 1697 1008 1...

result:

points 1.0 Correct

Test #6:

score: 0
Wrong Answer
time: 194ms
memory: 4332kb

input:

200000 87654321
33240 503
90721 868
64272 858
170928 616
92246 213
50575 59
148252 954
87639 739
328...

output:

100166
100170
163696 156715 137190 70822 35776 31953 67876 154752 198233 92978 76158 157196 168288 1...

result:

wrong answer Wrong answer!

Test #7:

score: 0
Wrong Answer
time: 239ms
memory: 5296kb

input:

200000 987654321
199051 7573
6332 5631
35615 9816
185684 9227
198894 8029
185684 2173
54203 2887
107...

output:

98970
98984
130989 134505 42096 162221 96841 74944 23020 198760 30257 149065 168626 187451 171688 93...

result:

wrong answer Wrong answer!

Test #8:

score: 10
Accepted
time: 523ms
memory: 8312kb

input:

444444 998244353
243276 2272
436596 1761
70822 1547
263965 942
280972 2658
87160 421
268504 2945
103...

output:

222615
222615
386384 25162 241797 441315 19606 67770 413312 261691 301783 98390 183750 302408 168372...

result:

points 1.0 Correct

Test #9:

score: 0
Wrong Answer
time: 586ms
memory: 10192kb

input:

500000 999999999
131412 807
486292 804
462352 1139
52896 196
426775 1655
18059 2099
224414 1308
2851...

output:

246062
261156
350774 259921 13036 181249 64852 87967 236769 124395 488521 12307 162688 357419 198632...

result:

wrong answer Wrong answer!

Test #10:

score: 10
Accepted
time: 683ms
memory: 10620kb

input:

500000 1000000000
42362 5090
327916 7618
221602 679
295161 1419
69703 4221
108614 6788
210597 6940
2...

output:

231450
231450
172853 146074 169748 424663 69113 60258 154947 196948 129939 117246 120758 135869 4585...

result:

points 1.0 Correct