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;
vector<int> fiine2;
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();
fiine.clear();
fiine.push_back(i+1);
// 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+1});
}
for (auto e: v) {
if (cost+e.first <= w) {
ans++;
cost += e.first;
fiine.push_back(e.second);
// cerr << "pushing back " << e.second << nl;
} else break;
}
global_max = max(global_max, ans);
if (global_max == ans) {
fiine2 = fiine;
// cerr << "hi i am here "<< nl;
}
}
cout << global_max << nl;
for (int i = 0; i < global_max; i++) cout << fiine2[i] << 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... |