Submission #817971

#TimeUsernameProblemLanguageResultExecution timeMemory
817971LiudasHiring (IOI09_hiring)C++17
47 / 100
1589 ms15236 KiB
#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; sort(ans.begin(), ans.end()); for(int i : ans){ cout << i << endl; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...