제출 #1290367

#제출 시각아이디문제언어결과실행 시간메모리
1290367BlockOGHiring (IOI09_hiring)C++20
60 / 100
376 ms18432 KiB
#include <bits/stdc++.h> // meeeooowwwww mrrowwww :3 // go play vivid/stasis!! now!!!! https://vividstasis.gay #define fo(i, a, b) for (auto i = (a); i < (b); i++) #define of(i, a, b) for (auto i = (b); i-- > (a);) #define f first #define s second #define pb push_back #define lb lower_bound #define ub upper_bound #define be(a) a.begin(), a.end() using namespace std; int ____init = []{ ios::sync_with_stdio(false); cin.tie(NULL), cout.tie(NULL); return 0; }(); struct Fraction { long long t, d; Fraction() : t(0), d(1) {} Fraction(long long t, long long d) : t(t), d(d) {} bool operator<(const Fraction &other) const { return t * other.d < other.t * d; } bool operator>(const Fraction &other) const { return t * other.d > other.t * d; } }; pair<Fraction, int> a[500000]; bool comp(pair<Fraction, int> l, pair<Fraction, int> r) { return l.f.d < r.f.d; } int main() { int n; long long w; cin >> n >> w; fo(i, 0, n) cin >> a[i].f.t >> a[i].f.d, a[i].s = i; sort(a, a + n); int res_size = 0, res_i = 0; Fraction mp; vector<pair<Fraction, int>> q; long long qsum = 0; fo(i, 0, n) { qsum += a[i].f.d; q.pb(a[i]), push_heap(be(q), comp); while (a[i].f.t * qsum > w * a[i].f.d) qsum -= q[0].f.d, pop_heap(be(q), comp), q.pop_back(); if (q.size() > res_size || q.size() == res_size && a[i].f < mp) { res_size = q.size(); res_i = i; mp = a[i].f; } } q.clear(); qsum = 0; fo(i, 0, res_i + 1) { qsum += a[i].f.d; q.pb(a[i]), push_heap(be(q), comp); while (a[i].f.t * qsum > w * a[i].f.d) qsum -= q[0].f.d, pop_heap(be(q), comp), q.pop_back(); } cout << q.size() << endl; for (auto [_, i] : q) cout << i + 1 << endl; }
#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...