Submission #748922

#TimeUsernameProblemLanguageResultExecution timeMemory
748922aaarghHiring (IOI09_hiring)C++17
28 / 100
1585 ms35984 KiB
#include <bits/stdc++.h> using namespace std; #define nl '\n' #define int long long #define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0) signed main() { io; int n, w; cin >> n >> w; double s[n], q[n]; for (int i = 0; i < n; i++) { cin >> s[i] >> q[i]; } double cost; double ans; vector<double> fiine; vector<double> fiine2; double global_max = 0; double temp = 0; multiset<pair<double,int>> v; for (int i = 0; i < n; i++) { cost = s[i]; ans = 1; v.clear(); fiine.clear(); fiine.push_back(i+1); // set i as being paid s[i] and take it by default for (int j = 0; j < n; j++) { if (i == j) continue; temp = (q[j]/q[i])*s[i]; if (temp >= s[j]) v.insert({temp,j+1}); } for (auto e: v) { if (cost+e.first <= w) { ans++; cost += e.first; fiine.push_back(e.second); // cerr << "pushing back " << e.second << nl; } else break; } global_max = max(global_max, ans); if (global_max == ans) { fiine2 = fiine; // cerr << "hi i am here "<< nl; } } cout << global_max << nl; for (int i = 0; i < global_max; i++) cout << fiine2[i] << nl; } /* fix a c (double) that each person is paid times their qual cost must be more than or equal to c times sum of qualifications maintain pq sorted people you can use in increasing q increase value of c, add more to pq once sum of everyone in pq exceeds how much you can use, pop max qual out c is some value of sk/qk */
#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...