Submission #748825

#TimeUsernameProblemLanguageResultExecution timeMemory
748825aaarghHiring (IOI09_hiring)C++17
4 / 100
1584 ms37996 KiB
#include <bits/stdc++.h>
using namespace std;
#define nl '\n'
#define int long long
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

signed main() {
	io; int n, w;
	cin >> n >> w;
	int s[n], q[n];
	for (int i = 0; i < n; i++) {
		cin >> s[i] >> q[i];
	}

	double cost;
	double ans;
	vector<int> fiine;
	double global_max = 0;
	double temp = 0;
	multiset<pair<double,int>> v;
	for (int i = 0; i < n; i++) {
		cost = s[i];
		ans = 1;
		v.clear();
		// set i as being paid s[i] and take it by default
		for (int j = 0; j < n; j++) {
			if (i == j) continue;
			temp = (q[j]/q[i])*s[i];
			if (temp >= s[j]) v.insert({temp,j});
		}


		for (auto e: v) {
			if (cost+e.first <= w) {
				ans++;
				cost += e.first;
			} else break;
		}
		global_max = max(global_max, ans);

	}
	cout << global_max << nl;
	for (int i = 0; i < global_max; i++) cout << 0 << nl;


}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...