Add solution for Codeforces problem 1985F
This commit is contained in:
parent
9c455619ee
commit
acb7f7a2e4
52
Codes/1985 F - Final Boss/1985F.cpp
Normal file
52
Codes/1985 F - Final Boss/1985F.cpp
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
#include <bits/stdc++.h>
|
||||||
|
using namespace std;
|
||||||
|
#define ll long long
|
||||||
|
#define endl '\n'
|
||||||
|
ll pow(ll x,ll y,ll m=1e9+7){ll ans=1;x%=m;while(y){if(y&1)ans=(ans*x)%m;x=(x*x)%m;y>>=1;}return ans;}
|
||||||
|
|
||||||
|
void solve()
|
||||||
|
{
|
||||||
|
ll h,n;
|
||||||
|
cin>>h>>n;
|
||||||
|
vector<int>a(n);
|
||||||
|
vector<int>b(n);
|
||||||
|
for(auto &i:a)
|
||||||
|
{
|
||||||
|
cin>>i;
|
||||||
|
h -=i;
|
||||||
|
}
|
||||||
|
for(auto &i:b) cin>>i;
|
||||||
|
if(h<=0)
|
||||||
|
{
|
||||||
|
cout<<1<<endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ll l=0, r=h*2e5, ans;
|
||||||
|
while(l<=r)
|
||||||
|
{
|
||||||
|
ll mid = l + (r-l)/2;
|
||||||
|
ll s=0;
|
||||||
|
for(int i=0; i<n; ++i)
|
||||||
|
s += (mid/b[i])*a[i];
|
||||||
|
if(h-s<=0)
|
||||||
|
{
|
||||||
|
ans=mid;
|
||||||
|
r=mid-1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
l = mid+1;
|
||||||
|
}
|
||||||
|
cout<<ans+1<<endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
signed main()
|
||||||
|
{
|
||||||
|
ios_base::sync_with_stdio(false), cin.tie(nullptr);
|
||||||
|
int TCS = 1;
|
||||||
|
cin >> TCS;
|
||||||
|
for (int TC = 1; TC <= TCS; ++TC)
|
||||||
|
{
|
||||||
|
// cout<<"Case "<<TC<<": ";
|
||||||
|
solve();
|
||||||
|
}
|
||||||
|
}
|
@ -344,6 +344,7 @@ This repository contains my solutions of Codeforces problems. They are in C++ la
|
|||||||
| 332 | 1985 C | Good Prefixes | [Question](https://codeforces.com/problemset/problem/1985/C) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1985%20C%20-%20Good%20Prefixes)
|
| 332 | 1985 C | Good Prefixes | [Question](https://codeforces.com/problemset/problem/1985/C) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1985%20C%20-%20Good%20Prefixes)
|
||||||
| 333 | 1985 D | Manhattan Circle | [Question](https://codeforces.com/problemset/problem/1985/D) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1985%20D%20-%20Manhattan%20Circle)
|
| 333 | 1985 D | Manhattan Circle | [Question](https://codeforces.com/problemset/problem/1985/D) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1985%20D%20-%20Manhattan%20Circle)
|
||||||
| 334 | 1985 E | Secret Box | [Question](https://codeforces.com/problemset/problem/1985/E) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1985%20E%20-%20Secret%20Box)
|
| 334 | 1985 E | Secret Box | [Question](https://codeforces.com/problemset/problem/1985/E) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1985%20E%20-%20Secret%20Box)
|
||||||
|
| 335 | 1985 F | Final Boss | [Question](https://codeforces.com/problemset/problem/1985/F) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1985%20F%20-%20Final%20Boss)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user