# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
602868 | Joshc | Hiring (IOI09_hiring) | C++11 | 388 ms | 29548 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
#define EPS 0.0000001
struct worker {
int id;
long long s, q;
};
struct comp {
bool operator() (worker& a, worker& b) {
return a.s*b.q < b.s*a.q;
}
};
struct comp2 {
bool operator() (worker& a, worker& b) {
return a.q < b.q;
}
};
int n, total=0, index=0, best=0;
long long w, t=0;
long double cost = 100000000000000000;
vector<worker> v;
priority_queue<worker, vector<worker>, comp2> pq;
void round(int num) {
t += v[num-1].q;
pq.push(v[num-1]);
while (!pq.empty() && t*v[num-1].s > w*v[num-1].q) {
t -= pq.top().q;
pq.pop();
}
if (pq.size() > total || (pq.size()==total && (t*pq.top().s)/((double)pq.top().q) < cost+EPS)) {
total = pq.size();
cost = (t*pq.top().s)/((long double)pq.top().q);
best = num;
}
}
int main() {
int s, q;
scanf("%d%lld", &n, &w);
for (int i=1; i<=n; i++) {
scanf("%d%d", &s, &q);
v.push_back({i, s, q});
}
sort(v.begin(), v.end(), comp());
for (int i=1; i<=n; i++) round(i);
printf("%d\n", total);
while (!pq.empty()) pq.pop();
t = 0;
cost = 100000000000000000;
for (int i=1; i<=best; i++) round(i);
vector<int> res;
while (!pq.empty()) {
res.push_back(pq.top().id);
pq.pop();
}
sort(res.begin(), res.end());
for (int i : res) printf("%d\n", i);
}
컴파일 시 표준 에러 (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... |