# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
433081 | ly20 | Hiring (IOI09_hiring) | C++17 | 1100 ms | 29152 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;
const int MAXN = 512345;
long long s[MAXN], q[MAXN];
int id[MAXN];
bool cmp(int a, int b) {
return s[a] * q[b] < s[b] * q[a];
}
int main() {
int n;
long long w;
scanf("%d %lld", &n, &w);
for(int i = 0; i < n; i++) {
id[i] = i;
scanf("%lld %lld", &s[i], &q[i]);
}
sort(id, id + n, cmp);
set <pair <long long, int> > s1;
int resp = -1, id1 = 0;
long long sum = 0;
for(int i = 0; i < n; i++) {
//printf("oi\n");
int cur = id[i];
sum += q[cur];
long long mn = s[cur];
s1.insert(make_pair(q[cur],cur));
while(sum * mn > w * q[cur]) {
sum -= (*(--s1.end())).first;
s1.erase(--s1.end());
}
//printf("%d %d\n", s1.size(), resp);
if((int) s1.size() > resp) {
//printf("oi\n");
resp = s1.size();
id1 = i;
}
}
//printf("%d\n", resp);
s1.clear();
sum = 0;
for(int i = 0; i <= id1; i++) {
int cur = id[i];
sum += q[cur];
long long mn = s[cur];
s1.insert(make_pair(q[cur],cur));
while(sum * mn > w * q[cur]) {
sum -= (*(--s1.end())).first;
s1.erase(--s1.end());
}
}
printf("%d\n", s1.size());
while(!s1.empty()) {
printf("%d\n", (*s1.begin()).second + 1);
s1.erase(s1.begin());
}
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... |