# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
490717 | ntabc05101 | Hiring (IOI09_hiring) | C++14 | 317 ms | 15032 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;
#define taskname ""
int main() {
if (fopen(taskname".inp", "r")) {
freopen(taskname".inp", "r", stdin);
freopen(taskname".out", "w", stdout);
}
else {
if (fopen(taskname".in", "r")) {
freopen(taskname".in", "r", stdin);
freopen(taskname".out", "w", stdout);
}
}
cin.tie(0)->sync_with_stdio(0);
int n; long long w; cin >> n >> w;
struct Sal {
int s, q; double r;
int idx;
bool operator < (const Sal &other) {
return r < other.r;
}
};
Sal a[n];
for (int i = 0; i < n; i++) {
cin >> a[i].s >> a[i].q;
a[i].r = 1. * a[i].s / a[i].q;
a[i].idx = i;
}
sort(a, a + n);
long long cur = 0;
priority_queue< array<int, 2> > pq;
int res = 0;
int j = 0;
for (int i = 0; i < n; i++) {
pq.push({a[i].q, 0});
cur += a[i].q;
while (a[i].r * cur > w) {
cur -= pq.top()[0]; pq.pop();
}
if (res < (int)pq.size()) {
res = pq.size(); j = i;
}
}
cout << res << "\n";
while (!pq.empty()) {
pq.pop();
}
cur = 0;
for (int i = 0; i <= j; i++) {
pq.push({a[i].q, a[i].idx});
cur += a[i].q;
while (a[i].r * cur > w) {
cur -= pq.top()[0]; pq.pop();
}
}
while (!pq.empty()) {
cout << 1 + pq.top()[1] << "\n"; pq.pop();
}
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... |