Submission #538719

#TimeUsernameProblemLanguageResultExecution timeMemory
538719fabijan_cikacHiring (IOI09_hiring)C++17
0 / 100
838 ms28444 KiB
#include <bits/stdc++.h> using namespace std; #define F first #define S second #define db double #define pp pair<db, db> #define ppp pair<db, pp> int n; db w; vector<db> sk; vector<db> q; vector<pair<db, int> > v; set<pair<db, int> > s; int siz = 0; vector<int> sol; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n >> w; sk.resize(n); q.resize(n); for (int i = 0; i < n; ++i){ cin >> sk[i] >> q[i]; v.push_back({sk[i] / q[i], i}); } sort(v.begin(), v.end()); db sum = 0; for (int i = 0; i < n; ++i){ s.insert({q[v[i].S], i}); sum += q[v[i].S]; while (!s.empty() && sum * v[i].F > w){ auto it = s.end(); --it; sum -= (*it).F; s.erase(it); } //siz = max(siz, (int)(s.size())); } cout << siz << '\n'; s.clear(); sum = 0; for (int i = 0; i < n; ++i){ s.insert({q[v[i].S], i}); sum += q[v[i].S]; while (!s.empty() && sum * v[i].F > w){ auto it = s.end(); --it; sum -= (*it).F; s.erase(it); } if (siz == (int)(s.size())){ for (auto x: s) sol.push_back(x.S + 1); break; } } sort(sol.begin(), sol.end()); for (int i = 0; i < sol.size(); ++i) cout << sol[i] << '\n'; return 0; }

Compilation message (stderr)

hiring.cpp: In function 'int main()':
hiring.cpp:52:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |     for (int i = 0; i < sol.size(); ++i)
      |                     ~~^~~~~~~~~~~~
#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...