# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
906469 |
2024-01-14T10:41:30 Z |
JakobZorz |
Hiring (IOI09_hiring) |
C++17 |
|
1500 ms |
12580 KB |
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<limits.h>
#include<math.h>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<iomanip>
#include<cstring>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using namespace std;
//const int MOD=1e9+7;
//typedef pair<ll,ll>Point;
//typedef pair<ll,ll>Line;
//#define x first
//#define y second
struct Obj{
ll s; // min salary
ll q; // skill
int i;
};
bool cmp(Obj&a,Obj&b){
return a.s*b.q<b.s*a.q;
}
void solve(){
int n;
ll w;
cin>>n>>w;
vector<Obj>arr(n);
for(int i=0;i<n;i++){
cin>>arr[i].s>>arr[i].q;
arr[i].i=i+1;
}
sort(arr.begin(),arr.end(),cmp);
int res=0;
int opt=0;
ll m1=0,m2=1; // spends m1/m2
for(int i=0;i<n;i++){
vector<ll>vals;
for(int j=0;j<i;j++)
vals.push_back(arr[j].q);
sort(vals.begin(),vals.end());
ll cost=arr[i].q;
if(cost*arr[i].s>w*arr[i].q)
continue;
int cres=0;
while(cres<(int)vals.size()){
if((cost+vals[cres])*arr[i].s<=w*arr[i].q){
cost+=vals[cres];
cres++;
}else{
break;
}
}
if(cres+1>res){
res=cres+1;
opt=i;
m1=cost*arr[i].s;
m2=arr[i].q;
//cout<<cost*arr[i].s<<"/"<<arr[i].q<<"\n";
}else if(cres+1==res){
if((__int128)cost*arr[i].s*m2<(__int128)m1*arr[i].q){
opt=i;
m1=cost;
m2=arr[i].q;
//cout<<cost*arr[i].s<<"/"<<arr[i].q<<"\n";
}
}
}
cout<<res<<"\n";
if(res){
cout<<arr[opt].i<<"\n";
int i=opt;
vector<pair<ll,int>>vals;
for(int j=0;j<i;j++)
vals.emplace_back(arr[j].q,arr[j].i);
sort(vals.begin(),vals.end());
ll cost=arr[i].q;
int cres=0;
while(cres<(int)vals.size()){
if((cost+vals[cres].first)*arr[i].s<=w*arr[i].q){
cost+=vals[cres].first;
cout<<vals[cres].second<<"\n";
cres++;
}else{
break;
}
}
}
}
int main(){
ios::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL);
//freopen("bank.in","r",stdin);freopen("bank.out","w",stdout);
int t=1;//cin>>t;
while(t--)solve();
return 0;
}
/*
4 100
5 1000
10 100
8 10
20 1
2
2
3
3 4
1 2
1 3
1 3
3
1
2
3
3 40
10 1
10 2
10 3
2
2
3
5 30
1 1
2 2
4 4
8 8
16 16
4
1
2
3
4
2 2
2 2
1 1
1
2
6 5
1 96
2 100
2 97
3 95
4 98
5 99
2
1
2
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Partially correct |
0 ms |
348 KB |
Partially correct |
6 |
Correct |
42 ms |
496 KB |
Output is correct |
7 |
Partially correct |
51 ms |
524 KB |
Partially correct |
8 |
Correct |
185 ms |
344 KB |
Output is correct |
9 |
Correct |
350 ms |
556 KB |
Output is correct |
10 |
Correct |
359 ms |
684 KB |
Output is correct |
11 |
Correct |
797 ms |
848 KB |
Output is correct |
12 |
Correct |
542 ms |
848 KB |
Output is correct |
13 |
Execution timed out |
1517 ms |
1152 KB |
Time limit exceeded |
14 |
Execution timed out |
1538 ms |
908 KB |
Time limit exceeded |
15 |
Execution timed out |
1540 ms |
992 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Partially correct |
1 ms |
348 KB |
Partially correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Execution timed out |
1563 ms |
1228 KB |
Time limit exceeded |
5 |
Execution timed out |
1548 ms |
2392 KB |
Time limit exceeded |
6 |
Execution timed out |
1528 ms |
7764 KB |
Time limit exceeded |
7 |
Execution timed out |
1506 ms |
9960 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
348 KB |
Output is correct |
2 |
Partially correct |
4 ms |
348 KB |
Partially correct |
3 |
Correct |
4 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
344 KB |
Output is correct |
2 |
Correct |
11 ms |
344 KB |
Output is correct |
3 |
Correct |
11 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
348 KB |
Output is correct |
2 |
Correct |
20 ms |
348 KB |
Output is correct |
3 |
Correct |
18 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1544 ms |
3308 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1557 ms |
5468 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1517 ms |
11132 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1554 ms |
12580 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |