9821 | 2024-03-08 16:49:34 | bovizdb | Jobstown-i milliomos | cpp17 | Wrong answer 16/100 | 3ms | 4904 KiB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define pll pair<ll, ll>
#define fs first
#define sc second
#define vll vector<ll>
#define v2d vector<vector<ll>>
#define vpll vector<pll>
#define qll queue<ll>
#define stll stack<ll>
#define sll set<ll>
#define mll map<ll, ll>
ll n, l;
vll t, p;
map <double, vector<pll>> m;
priority_queue<double> q;
void solve()
{
cin >> n >> l;
t.resize(n);
p.resize(n);
for (ll i = 0; i < n; i++) cin >> t[i];
for (ll i = 0; i < n; i++) cin >> p[i];
for (ll i = 0; i < n; i++)
{
double a = (double) p[i] / (double) t[i];
q.push(a);
m[a].push_back({p[i], t[i]});
}
ll ans = 0;
while(l > 0 && q.size() > 0)
{
ll mx = 0, mxl = 0;
for (auto i : m[q.top()])
{
ll x = l/i.sc;
if (x*i.fs > mx)
{
mx = x*i.fs;
mxl = l-x*i.sc;
}
}
if (mx == 0)
{
q.pop();
}
else
{
ans += mx;
l = mxl;
}
}
cout << ans;
}
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
ll t = 1;
//cin >> t;
while(t--)
{
solve();
}
return 0;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1760 KiB | ||||
2 | Accepted | 3ms | 1924 KiB | ||||
subtask2 | 0/25 | ||||||
3 | Accepted | 3ms | 2136 KiB | ||||
4 | Accepted | 3ms | 2372 KiB | ||||
5 | Wrong answer | 3ms | 2508 KiB | ||||
6 | Wrong answer | 3ms | 2496 KiB | ||||
7 | Wrong answer | 3ms | 2904 KiB | ||||
8 | Wrong answer | 3ms | 3000 KiB | ||||
9 | Accepted | 3ms | 3212 KiB | ||||
10 | Accepted | 3ms | 3420 KiB | ||||
11 | Accepted | 3ms | 3620 KiB | ||||
12 | Accepted | 3ms | 3912 KiB | ||||
13 | Accepted | 3ms | 4188 KiB | ||||
14 | Accepted | 3ms | 3932 KiB | ||||
subtask3 | 16/16 | ||||||
15 | Accepted | 3ms | 4260 KiB | ||||
16 | Accepted | 3ms | 4284 KiB | ||||
17 | Accepted | 3ms | 4196 KiB | ||||
18 | Accepted | 3ms | 4292 KiB | ||||
19 | Accepted | 3ms | 4420 KiB | ||||
20 | Accepted | 3ms | 4432 KiB | ||||
21 | Accepted | 3ms | 4468 KiB | ||||
subtask4 | 0/59 | ||||||
22 | Accepted | 3ms | 4364 KiB | ||||
23 | Accepted | 2ms | 4360 KiB | ||||
24 | Wrong answer | 3ms | 4432 KiB | ||||
25 | Wrong answer | 3ms | 4424 KiB | ||||
26 | Wrong answer | 3ms | 4556 KiB | ||||
27 | Accepted | 3ms | 4716 KiB | ||||
28 | Accepted | 3ms | 4580 KiB | ||||
29 | Accepted | 3ms | 4840 KiB | ||||
30 | Accepted | 2ms | 4612 KiB | ||||
31 | Accepted | 3ms | 4616 KiB | ||||
32 | Wrong answer | 3ms | 4652 KiB | ||||
33 | Wrong answer | 3ms | 4904 KiB |