Submission
Status:
[PPP-SSSSSSSSSSS]
Subtask/Task Score:
{0/100}
Score: 0
User: qweqwe
Problemset: laracroft
Language: cpp
Time: 0.002 second
Submitted On: 2025-10-25 14:27:00
#include <bits/stdc++.h>
#define speed cin.tie(0)->sync_with_stdio(0)
#define ll long long
#define pii pair<int,int>
using namespace std;
struct stats{
int val,we;
bool operator<(const stats &other) const{
if (val!=other.val) return val>other.val;
return we<other.val;
}
};
int main(){
speed;
int n,k;cin >> n >> k;
vector<stats> invs(n);
for (int i=0;i<n;i++){
cin >> invs[i].val;
}
for (int i=0;i<n;i++){
cin >> invs[i].we;
}int sum=0,w=0;
sort(invs.begin(),invs.end());
for (stats i:invs){
if (i.we<=k){
k-=i.we;
w+=i.we;
sum+=i.val;
}//cout << sum << " " << w << "\n";
}cout << sum << " " << w;
return 0;
}