제출 #1290366

#제출 시각아이디문제언어결과실행 시간메모리
1290366BlockOGHiring (IOI09_hiring)C++20
45 / 100
1596 ms13964 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);

    vector<int> res;
    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()) {
            res.clear();
            for (auto [_, j] : q) res.pb(j);
            mp = a[i].f;
        }
    }

    cout << res.size() << endl;
    for (int i : res) 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...