9683 | 2024-02-25 12:59:40 | bovizdb | Jobstown-i milliomos | cpp17 | Wrong answer 0/100 | 2.085s | 3740 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;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1892 KiB | ||||
2 | Accepted | 3ms | 2396 KiB | ||||
subtask2 | 0/25 | ||||||
3 | Accepted | 3ms | 2400 KiB | ||||
4 | Accepted | 3ms | 2616 KiB | ||||
5 | Wrong answer | 3ms | 2844 KiB | ||||
6 | Wrong answer | 3ms | 3004 KiB | ||||
7 | Wrong answer | 3ms | 2956 KiB | ||||
8 | Wrong answer | 3ms | 2952 KiB | ||||
9 | Accepted | 3ms | 2956 KiB | ||||
10 | Accepted | 3ms | 3248 KiB | ||||
11 | Accepted | 3ms | 3204 KiB | ||||
12 | Accepted | 3ms | 3360 KiB | ||||
13 | Accepted | 3ms | 3368 KiB | ||||
14 | Accepted | 2ms | 3304 KiB | ||||
subtask3 | 0/16 | ||||||
15 | Accepted | 326ms | 3372 KiB | ||||
16 | Accepted | 175ms | 3344 KiB | ||||
17 | Accepted | 159ms | 3368 KiB | ||||
18 | Accepted | 71ms | 3300 KiB | ||||
19 | Time limit exceeded | 2.061s | 3308 KiB | ||||
20 | Time limit exceeded | 2.073s | 2664 KiB | ||||
21 | Time limit exceeded | 2.081s | 3660 KiB | ||||
subtask4 | 0/59 | ||||||
22 | Accepted | 3ms | 3488 KiB | ||||
23 | Accepted | 2ms | 3480 KiB | ||||
24 | Wrong answer | 1.916s | 3560 KiB | ||||
25 | Wrong answer | 266ms | 3552 KiB | ||||
26 | Wrong answer | 100ms | 3560 KiB | ||||
27 | Accepted | 326ms | 3560 KiB | ||||
28 | Accepted | 179ms | 3584 KiB | ||||
29 | Accepted | 159ms | 3740 KiB | ||||
30 | Accepted | 71ms | 3700 KiB | ||||
31 | Time limit exceeded | 2.085s | 3740 KiB | ||||
32 | Time limit exceeded | 2.02s | 2752 KiB | ||||
33 | Time limit exceeded | 2.072s | 3592 KiB |