Submission #964984

#TimeUsernameProblemLanguageResultExecution timeMemory
964984fzyzzz_zHiring (IOI09_hiring)C++17
60 / 100
604 ms31784 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; #define fs first #define sc second int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; ll k; cin >> n >> k; vector<pair<int, int>> a(n); vector<int> ord(n); for (int i = 0; i < n; ++i) { cin >> a[i].sc >> a[i].fs; ord[i] = i; } sort(ord.begin(), ord.end(), [&](int & x, int & y){ if (a[x].fs * a[y].sc == a[x].sc * a[y].fs) return a[x].sc < a[y].sc; return (a[y].fs * a[x].sc <= a[y].sc * a[x].fs); }); set<pair<int, int>> st; int ans = 0; ll cs = 0; for (int i = 0; i < n; ++i) { int x = a[ord[i]].fs, y = a[ord[i]].sc; cs += x; st.insert({x, i}); // cout << "at " << i << ' ' << ord[i] << ' ' << x << ' ' << y << '\n'; while (cs * y > k * x) { pair<int, int> v = *st.rbegin(); cs -= v.fs; st.erase(v); } // cout << cs << ' ' << '\n'; // cout << "S " << st.size() << '\n'; // for (auto x: st) { // cout << x.sc << '\n'; // } if (st.size() > ans) { ans = st.size(); } } st.clear(); cs = 0; for (int i = 0; i < n; ++i) { int x = a[ord[i]].fs, y = a[ord[i]].sc; cs += x; st.insert({x, ord[i]}); while (cs * y > k * x) { pair<int, int> v = *st.rbegin(); cs -= v.fs; st.erase(v); } if (st.size() == ans) { cout << ans << "\n"; set<int> xs; for (auto v: st) xs.insert(v.sc); for (auto v: xs) { cout << v + 1 << "\n"; } return 0; } } assert(false); return 0; }

Compilation message (stderr)

hiring.cpp: In function 'int main()':
hiring.cpp:51:17: warning: comparison of integer expressions of different signedness: 'std::set<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   51 |   if (st.size() > ans) {
      |       ~~~~~~~~~~^~~~~
hiring.cpp:69:17: warning: comparison of integer expressions of different signedness: 'std::set<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   69 |   if (st.size() == ans) {
      |       ~~~~~~~~~~^~~~~~
#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...