이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
double global_max = 0;
double temp = 0;
multiset<double> 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);
}
for (auto e: v) {
if (cost+e <= w) {
ans++;
cost += e;
} else break;
}
global_max = max(global_max, ans);
}
cout << global_max << 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... |