# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
964987 | fzyzzz_z | Hiring (IOI09_hiring) | C++17 | 531 ms | 20220 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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, at = 0;
ll cs = 0;
ll tcb = 1, tct = 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});
while (cs * y > k * x) {
pair<int, int> v = *st.rbegin();
cs -= v.fs;
st.erase(v);
}
if (st.size() > ans) {
ans = st.size();
tct = cs * y;
tcb = x;
at = i;
} else if (cs * y * tcb > tct * x && st.size() == ans) {
tct = cs * y;
tcb = x;
at = i;
}
}
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 (at == i) {
cout << ans << "\n";
for (auto v: st) {
cout << v.sc + 1 << "\n";
}
return 0;
}
}
assert(false);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |