Submission #446472

#TimeUsernameProblemLanguageResultExecution timeMemory
446472JerryLiu06Hiring (IOI09_hiring)C++17
100 / 100
441 ms14512 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using db = double; using str = string; using pi = pair<int, int>; using pl = pair<ll, ll>; using pd = pair<db, db>; using vi = vector<int>; using vb = vector<bool>; using vl = vector<ll>; using vd = vector<db>; using vs = vector<str>; using vpi = vector<pi>; using vpl = vector<pl>; using vpd = vector<pd>; #define mp make_pair #define f first #define s second #define sz(x) (int)(x).size() #define bg(x) begin(x) #define all(x) bg(x), end(x) #define sor(x) sort(all(x)) #define rsz resize #define ins insert #define ft front() #define bk back() #define pb push_back #define pf push_front #define lb lower_bound #define ub upper_bound #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define F0R(i, a) FOR(i, 0, a) #define ROF(i, a, b) for (int i = (b) - 1; i >= (a); i--) #define R0F(i, a) ROF(i, 0, a) #define EACH(a, x) for (auto& a : x) ll cdiv(ll a, ll b) { return a / b + ((a ^ b) > 0 && a % b); } ll fdiv(ll a, ll b) { return a / b - ((a ^ b) < 0 && a % b); } template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; } template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; } template<class T> void remDup(vector<T>& v) { sor(v); v.erase(unique(all(v)), v.end()); } const int MOD = 1e9 + 7; const int MX = 5e5 + 10; const ll INF = 1e18; int N; ll W; int S[MX], Q[MX]; vi A; priority_queue<pi> PQ; ll tot = 0; int maxSize = 0; ll NUM = 1, DEM = 1; int indMax = 0; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cin >> N >> W; FOR(i, 1, N + 1) cin >> S[i] >> Q[i]; A.rsz(N); iota(all(A), 1); sort(all(A), [&](int a, int b) { return S[a] * Q[b] < S[b] * Q[a]; }); EACH(C, A) { PQ.push({Q[C], C}); tot += Q[C]; while (tot * S[C] > W * Q[C]) { tot -= PQ.top().f; PQ.pop(); } if (sz(PQ) > maxSize || (sz(PQ) == maxSize && NUM * Q[C] > tot * S[C] * DEM)) { maxSize = sz(PQ); NUM = tot * S[C]; DEM = Q[C]; indMax = C; } } while (!PQ.empty()) PQ.pop(); tot = 0; if (maxSize == 0) { cout << "0" << "\n"; return 0; } EACH(C, A) { PQ.push({Q[C], C}); tot += Q[C]; while (tot * S[C] > W * Q[C]) { tot -= PQ.top().f; PQ.pop(); } if (C == indMax) { cout << sz(PQ) << "\n"; while (!PQ.empty()) { cout << PQ.top().s << "\n"; PQ.pop(); } break; } } }

Compilation message (stderr)

hiring.cpp: In function 'int main()':
hiring.cpp:80:5: warning: this 'while' clause does not guard... [-Wmisleading-indentation]
   80 |     while (!PQ.empty()) PQ.pop(); tot = 0;
      |     ^~~~~
hiring.cpp:80:35: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'while'
   80 |     while (!PQ.empty()) PQ.pop(); tot = 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...