# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
817983 | Liudas | Hiring (IOI09_hiring) | C++17 | 1581 ms | 15644 KiB |
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>
#define endl "\n"
using namespace std;
struct node{
double Q;
double P;
int id;
};
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
long long N, W;
double H = 0, BP = 1e18;
cin >> N >> W;
vector<node> arr(N);
vector<int> ans;
for(int i = 0; i < N; i ++){
cin >> arr[i].P >> arr[i].Q;
arr[i].id = i + 1;
}
sort(arr.begin(), arr.end(), [&](node a, node b){return a.Q < b.Q;});
double l = 0, r = 1e16;
for(int i = 0; i < N; i ++){
node start = arr[i];
double kof = start.P/start.Q;
double price = 0;
double c = 0;
vector<int> brr;
for(node j : arr){
if(kof >= j.P/j.Q && (price + j.Q) * kof <= W){
c ++;
price += j.Q;
brr.push_back(j.id);
}
}
if(H < c){
ans = brr;
BP = price * kof;
}
else if(H == c && price * kof <= BP){
ans = brr;
BP = price * kof;
}
H = max(c, H);
}
cout << H << endl;
sort(ans.begin(), ans.end());
for(int i : ans){
cout << i << endl;
}
return 0;
}
Compilation message (stderr)
# | 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... |