# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1009695 | ZeroCool | Hiring (IOI09_hiring) | C++14 | 212 ms | 24820 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;
#define ll long long
#define ar array
#define int long long
#define ld long double
const int N = (1 << 18) + 20;
const int M = 105;
const int MOD = 998244353;
struct Node{
int s, q, id;
bool operator<(Node o) const {
return s * o.q < q * o.s;
}
};
signed main(){ios::sync_with_stdio(false);cin.tie(0);
int n, w;
cin>>n>>w;
//cout<<n;
Node A[n];
for(int i = 0;i < n;i++){
cin>>A[i].s>>A[i].q;
A[i].id = i;
}
sort(A, A+n);
int l = 0;
int ans = 0;
int sum = 0;
priority_queue<int> q;
for(int r = 0;r < n;r++){
sum += A[r].q;
q.push(A[r].q);
while(sum * A[r].s > w * A[r].q){
sum -= q.top();
q.pop();
}
ans = max(ans, (int)q.size());
}
sum = 0;
cout<<ans<<'\n';
if(ans){
priority_queue<ar<int, 2>> q;
for(int r = 0;r < n;r++){
sum += A[r].q;
q.push({A[r].q, A[r].id});
while(sum * A[r].s > w * A[r].q){
sum -= q.top()[0];
q.pop();
}
if(q.size() == ans){
while(q.size()){
cout<<q.top()[1] + 1<<'\n';
q.pop();
}
return 0;
return 0;
}
}
}
}
// abba
//baab
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... |