이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
struct node{
double Q;
double P;
int id;
};
int main()
{
long long N, W;
double H = 0, BP = 1e10;
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;
}
for(int i = 0; i < N; i ++){
node start = arr[i];
double price = 0;
double c = 0;
sort(arr.begin(), arr.end(), [&](node a, node b){return a.Q * start.P < b.Q * start.P;});
vector<int> brr;
for(node j : arr){
if(start.P * j.Q >= j.P * start.Q && (price + j.Q) * start.P <= W * start.Q){
c ++;
price += j.Q;
brr.push_back(j.id);
}
}
if(H < c){
ans = brr;
BP = price * start.P / start.Q;
}
else if(H == c && price * start.P / start.Q <= BP){
ans = brr;
BP = price * start.P / start.Q;
}
H = max(c, H);
}
cout << H << endl;
for(int i : ans){
cout << i << endl;
}
return 0;
}
# | 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... |