98212024-03-08 16:49:34bovizdbJobstown-i milliomoscpp17Wrong answer 16/1003ms4904 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;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1760 KiB
2Accepted3ms1924 KiB
subtask20/25
3Accepted3ms2136 KiB
4Accepted3ms2372 KiB
5Wrong answer3ms2508 KiB
6Wrong answer3ms2496 KiB
7Wrong answer3ms2904 KiB
8Wrong answer3ms3000 KiB
9Accepted3ms3212 KiB
10Accepted3ms3420 KiB
11Accepted3ms3620 KiB
12Accepted3ms3912 KiB
13Accepted3ms4188 KiB
14Accepted3ms3932 KiB
subtask316/16
15Accepted3ms4260 KiB
16Accepted3ms4284 KiB
17Accepted3ms4196 KiB
18Accepted3ms4292 KiB
19Accepted3ms4420 KiB
20Accepted3ms4432 KiB
21Accepted3ms4468 KiB
subtask40/59
22Accepted3ms4364 KiB
23Accepted2ms4360 KiB
24Wrong answer3ms4432 KiB
25Wrong answer3ms4424 KiB
26Wrong answer3ms4556 KiB
27Accepted3ms4716 KiB
28Accepted3ms4580 KiB
29Accepted3ms4840 KiB
30Accepted2ms4612 KiB
31Accepted3ms4616 KiB
32Wrong answer3ms4652 KiB
33Wrong answer3ms4904 KiB