Submission #507569

#TimeUsernameProblemLanguageResultExecution timeMemory
507569tabrHiring (IOI09_hiring)C++17
47 / 100
679 ms35452 KiB
#include <bits/stdc++.h> using namespace std; #ifdef tabr #include "library/debug.cpp" #else #define debug(...) #endif int main() { ios::sync_with_stdio(false); cin.tie(0); int n; long long w; cin >> n >> w; vector<pair<int, int>> a(n); for (int i = 0; i < n; i++) { cin >> a[i].first >> a[i].second; } sort(a.begin(), a.end(), [&](auto x, auto y) { if (x.first * y.second != x.second * y.first) { return x.first * y.second < x.second * y.first; } return x.first < y.first; }); multiset<pair<int, int>> st; int sum = 0; int ans = 0; for (int i = 0; i < n; i++) { sum += a[i].second; st.emplace(a[i].second, i); while (sum * 1LL * a[i].first > w * a[i].second) { auto it = prev(st.end()); sum -= it->first; st.erase(it); } ans = max(ans, (int) st.size()); } st.clear(); sum = 0; for (int i = 0; i < n; i++) { sum += a[i].second; st.emplace(a[i].second, i); while (sum * 1LL * a[i].first > w * a[i].second) { auto it = prev(st.end()); sum -= it->first; st.erase(it); } if ((int) st.size() == ans) { cout << ans << '\n'; for (auto p : st) { cout << p.second + 1 << '\n'; } break; } } 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...