Submission #817980

#TimeUsernameProblemLanguageResultExecution timeMemory
817980LiudasHiring (IOI09_hiring)C++17
54 / 100
1587 ms27488 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 = 1e18; cin >> N >> W; vector<node> arr(N), crr; vector<int> ans; for(int i = 0; i < N; i ++){ cin >> arr[i].P >> arr[i].Q; arr[i].id = i + 1; } crr = arr; for(int i = 0; i < N; i ++){ node start = crr[i]; double kof = start.P/start.Q; 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; //cout << endl << endl << i << endl; for(node j : arr){ //cout << j.id << " " << start.P * j.Q << " " << j.P * start.Q << " " << ((price + j.Q) * start.P / start.Q <= W) << endl; if(kof >= j.P/j.Q && (price + j.Q) * kof <= W){ //cout <<"taken" << endl; c ++; price += j.Q; brr.push_back(j.id); } } //cout << i << " " << price * start.P / start.Q << " " << c << endl; if(H < c){ ans = brr; BP = price * kof; } else if(H == c && price * kof <= BP){ //cout << "cons"<<i << " " << c << endl; 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; }
#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...