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 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 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... |