# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
433088 | 2021-06-18T20:34:06 Z | ly20 | Hiring (IOI09_hiring) | C++17 | 1094 ms | 24900 KB |
#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; long long ccur = 0, cst = 0, qt = 1; 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()); } ccur = sum * mn; //printf("%d %d\n", s1.size(), resp); if((int) s1.size() > resp || ((int) s1.size() == resp && cst * q[cur] > ccur * qt)) { //printf("oi\n"); resp = s1.size(); qt = q[cur]; cst = ccur; 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()); vector <int> rsp; while(!s1.empty()) { rsp.push_back((*s1.begin()).second + 1); s1.erase(s1.begin()); } sort(rsp.begin(), rsp.end()); for(int i = 0; i < rsp.size(); i++) { printf("%d\n", rsp[i]); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 2 ms | 392 KB | Output is correct |
7 | Correct | 2 ms | 332 KB | Output is correct |
8 | Correct | 2 ms | 332 KB | Output is correct |
9 | Correct | 4 ms | 460 KB | Output is correct |
10 | Correct | 5 ms | 460 KB | Output is correct |
11 | Correct | 6 ms | 460 KB | Output is correct |
12 | Correct | 9 ms | 852 KB | Output is correct |
13 | Correct | 8 ms | 460 KB | Output is correct |
14 | Correct | 11 ms | 844 KB | Output is correct |
15 | Correct | 13 ms | 856 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 16 ms | 1212 KB | Output is correct |
5 | Correct | 42 ms | 2420 KB | Output is correct |
6 | Correct | 574 ms | 13580 KB | Output is correct |
7 | Correct | 699 ms | 19188 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 1 ms | 332 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 1 ms | 332 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 2 ms | 332 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 130 ms | 5512 KB | Output is correct |
2 | Correct | 125 ms | 5528 KB | Output is correct |
3 | Correct | 129 ms | 5480 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 233 ms | 9452 KB | Output is correct |
2 | Correct | 214 ms | 9360 KB | Output is correct |
3 | Correct | 220 ms | 9348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 827 ms | 20888 KB | Output is correct |
2 | Correct | 818 ms | 20932 KB | Output is correct |
3 | Correct | 786 ms | 21084 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1055 ms | 24820 KB | Output is correct |
2 | Correct | 1094 ms | 24900 KB | Output is correct |
3 | Correct | 1065 ms | 24768 KB | Output is correct |