96832024-02-25 12:59:40bovizdbJobstown-i milliomoscpp17Wrong answer 0/1002.085s3740 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, priority_queue<pair<ll, ll>>> m, m2;
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({p[i], t[i]});
    }
    ll ans = 0;
    while(l > 0 && q.size() > 0)
    {
        if (m[q.top()].size() == 0)
        {
            q.pop();
            continue;
        }
        if (m[q.top()].top().sc > l) m[q.top()].pop();
        else
        {
            l -= m[q.top()].top().sc;
            ans += m[q.top()].top().fs;
        }
    }
    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
1Accepted3ms1892 KiB
2Accepted3ms2396 KiB
subtask20/25
3Accepted3ms2400 KiB
4Accepted3ms2616 KiB
5Wrong answer3ms2844 KiB
6Wrong answer3ms3004 KiB
7Wrong answer3ms2956 KiB
8Wrong answer3ms2952 KiB
9Accepted3ms2956 KiB
10Accepted3ms3248 KiB
11Accepted3ms3204 KiB
12Accepted3ms3360 KiB
13Accepted3ms3368 KiB
14Accepted2ms3304 KiB
subtask30/16
15Accepted326ms3372 KiB
16Accepted175ms3344 KiB
17Accepted159ms3368 KiB
18Accepted71ms3300 KiB
19Time limit exceeded2.061s3308 KiB
20Time limit exceeded2.073s2664 KiB
21Time limit exceeded2.081s3660 KiB
subtask40/59
22Accepted3ms3488 KiB
23Accepted2ms3480 KiB
24Wrong answer1.916s3560 KiB
25Wrong answer266ms3552 KiB
26Wrong answer100ms3560 KiB
27Accepted326ms3560 KiB
28Accepted179ms3584 KiB
29Accepted159ms3740 KiB
30Accepted71ms3700 KiB
31Time limit exceeded2.085s3740 KiB
32Time limit exceeded2.02s2752 KiB
33Time limit exceeded2.072s3592 KiB