Submission #302438

# Submission time Handle Problem Language Result Execution time Memory
302438 2020-09-18T16:52:25 Z Nucleist Hiring (IOI09_hiring) C++14
100 / 100
1463 ms 40812 KB
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
#define pb push_back
#define debug(x) cerr << " " << x << " " << #x << endl;
int main(){
	long long nb,w;
	cin>>nb>>w;
	vector<pair<long double,long long>>g;
	vector<long long>k1,k2;
	for (long long i = 0; i < nb; ++i)
	{
		long double s,q;
		cin>>s>>q;
		g.pb({s/q,i});
		k1.pb(s);
		k2.pb(q);
	}
	sort(all(g));
	priority_queue<pair<long double,long long>>g2;
	long double cur=0;
	pair<pair<long long,long long>,int> ans={{0,0},0};
	for (long long i = 0; i < nb; ++i)
	{
		g2.push({k2[g[i].second],i});
		if(i){
			cur/=(g[i-1].first);
		}
		cur*=g[i].first;
		cur+=k1[g[i].second];
		while(!(g2.empty()) && cur>w){
			cur-=((g2.top().first)*g[i].first);
			g2.pop();
		}
		ans=max(ans,{{(long long)(g2.size()),-cur},i});
	}
	cout<<ans.first.first<<'\n';
	while(!(g2.empty()))
	{
		g2.pop();
	}
	cur=0;
	for (long long i = 0; i <= ans.second; ++i)
	{
		g2.push({k2[g[i].second],i});
		if(i){
			cur/=(g[i-1].first);
		}
		cur*=g[i].first;
		cur+=k1[g[i].second];
		while(!(g2.empty()) && cur>w){
			cur-=((g2.top().first)*g[i].first);
			g2.pop();
		}
	}
	while(!(g2.empty()))
	{
		cout<<g[g2.top().second].second+1;
		g2.pop();
		if(g2.size())cout<<'\n';
	}
    return 0; 
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 4 ms 512 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 6 ms 512 KB Output is correct
9 Correct 10 ms 768 KB Output is correct
10 Correct 13 ms 928 KB Output is correct
11 Correct 13 ms 768 KB Output is correct
12 Correct 18 ms 1276 KB Output is correct
13 Correct 18 ms 1020 KB Output is correct
14 Correct 29 ms 1400 KB Output is correct
15 Correct 34 ms 1656 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 48 ms 1908 KB Output is correct
5 Correct 138 ms 6116 KB Output is correct
6 Correct 816 ms 24764 KB Output is correct
7 Correct 1099 ms 35052 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 512 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 3 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 285 ms 9436 KB Output is correct
2 Correct 294 ms 9692 KB Output is correct
3 Correct 283 ms 9436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 491 ms 17236 KB Output is correct
2 Correct 497 ms 17232 KB Output is correct
3 Correct 495 ms 17104 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1277 ms 37308 KB Output is correct
2 Correct 1271 ms 37200 KB Output is correct
3 Correct 1268 ms 37168 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1463 ms 40524 KB Output is correct
2 Correct 1450 ms 40576 KB Output is correct
3 Correct 1445 ms 40812 KB Output is correct