This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define MAXN (1000005)
int main(){
ios_base::sync_with_stdio(false);cin.tie(0);
ll N;
ld W;
cin>>N>>W;
ld S[N], Q[N]; //min salary, qualification
pair<pair<ld,ld>,ld> arr[N];
for(ll i = 0;i < N;i++){
cin>>S[i]>>Q[i];
arr[i] = {{Q[i],S[i]},i};
}
sort(arr,arr + N);
ld budget = W;
ld prev = 0;
ll ans = 0;
for(ll i = 0;i < N;i++){
ld needed = arr[i].first.second;
if(i > 0){
needed = max(needed,(arr[i].first.first / arr[i - 1].first.first) * prev);
}
if(budget >= needed){
budget -= needed;
prev = needed;
ans++;
}else{
break;
}
}
cout<<ans<<'\n';
for(ll i = 0;i < ans;i++){
cout<<i + 1<<'\n';
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |