# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
881231 | Matjaz | Hiring (IOI09_hiring) | C++14 | 569 ms | 17900 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//
// IOI2009Salesman.cpp
//
//
// Created by Matjaz Leonardis on 11/11/2023.
//
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
struct worker{
long long S;
long long Q;
int index;
bool operator<(const worker& other) const {
return S * other.Q < other.S * Q;
}
};
struct w2{
long long Q;
int index;
bool operator<(const w2& other) const {
return Q < other.Q;
}
};
int N;
long long W;
int main(){
cin >> N >> W;
vector<worker> w(N);
for (int i=0;i<N;i++){
cin >> w[i].S >> w[i].Q;
w[i].index = i + 1;
}
sort(w.begin(), w.end());
long long total = 0;
priority_queue<w2> Q;
int best = 0;
long long minMoneyQnS = 0;
long long minMoneyQd = 0;
int besti = 0;
for (int i=0;i<N;i++){
w2 x;
x.Q = w[i].Q;
x.index = w[i].index;
Q.push(x);
total += x.Q;
while (total * w[i].S > W * w[i].Q){
total -= Q.top().Q;
Q.pop();
}
if (Q.size() == best){
if (total * w[i].S * minMoneyQd < w[i].Q * minMoneyQnS){
minMoneyQd = w[i].Q;
minMoneyQnS = total * w[i].S;
besti = i;
}
}
if (Q.size() > best){
best = Q.size();
minMoneyQd = w[i].Q;
minMoneyQnS = total * w[i].S;
besti = i;
}
}
cout << best << endl;
total = 0;
while (!Q.empty()) Q.pop();
for (int i=0;i<N;i++){
w2 x;
x.Q = w[i].Q;
x.index = w[i].index;
Q.push(x);
total += x.Q;
while (total * w[i].S > W * w[i].Q){
total -= Q.top().Q;
Q.pop();
}
if (i == besti){
while (!Q.empty()){
cout << Q.top().index << endl;
Q.pop();
}
break;
}
}
return 0;
}
컴파일 시 표준 에러 (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... |