-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathC_Suiss.cpp
More file actions
51 lines (45 loc) · 836 Bytes
/
C_Suiss.cpp
File metadata and controls
51 lines (45 loc) · 836 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <bits/stdc++.h>
using namespace std;
typedef long long ll ll;
ll portfolio_profit_maximisation(ll maxSum, vector<ll> a, vector<ll> b) {
ll n=a.size();
ll m=b.size();
a.push_back(1e10);
b.push_back(1e10);
int i=0,j=0;
ll sum=0;
ll ans=0;
while(i<n and j<m)
{
ll x=a[i];
ll y=b[j];
sum+=min(x);
if(sum>maxSum)
{
break;
}
if(x<y)
i+=1;
else
j+=1;
ans+=1;
}
return ans;
}
int main()
{
ios::sync_with_stdio(false);
ll n, m, x;
cin >> n >> m >> x;
vector<ll> a(n);
vector<ll> b(m);
for (ll i = 0; i < n; ++i) {
cin >> a[i];
}
for (ll i = 0; i < m; ++i) {
cin >> b[i];
}
ll result = portfolio_profit_maximisation(maxSum, a, b);
cout << result;
return 0;
}