| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 297152 | Harry464 | Hiring (IOI09_hiring) | C++14 | 1035 ms | 32600 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 <iostream>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int n;
double w;
cin >> n >> w;
vector <pair<pair<double,int>,pair<double,double>>> c(n);
for (int i = 0; i < n; i++){
double p, q;
cin >> p >> q;
c[i] = make_pair(make_pair(p/q,i+1),make_pair(p,q));
}
sort(c.begin(),c.end());
double totq = 0;
priority_queue<double> kju;
int najs = 0, ind;
double najcijena = 1000000000;
for (int i = 0; i < n; i++){
kju.push(c[i].second.second);
totq += c[i].second.second;
double gran = w / c[i].first.first;
while (totq > gran){
totq -= kju.top();
kju.pop();
}
double cijena = totq*c[i].first.first;
if (kju.size() > najs || (kju.size() == najs && najcijena > cijena)){
najs = kju.size();
ind = i;
najcijena = cijena;
}
}
totq = 0;
priority_queue<pair<double,int>> kju2;
for (int i = 0; i <= ind; i++){
kju2.push(make_pair(c[i].second.second,c[i].first.second));
totq += c[i].second.second;
}
double gran = w / c[ind].first.first;
while (totq > gran){
totq -= kju2.top().first;
kju2.pop();
}
cout << kju2.size() << endl;
vector <int> rjesenje;
while (!kju2.empty()){
rjesenje.push_back(kju2.top().second);
kju2.pop();
}
sort(rjesenje.begin(),rjesenje.end());
for (int i = 0; i < rjesenje.size(); i++)
cout << rjesenje[i] << endl;
}
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... | ||||
