Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- long long m,n,t[25];
- bool check(long long x)
- {
- int S=0;
- for(int i=1;i<=n;i++)
- {
- S+=x/t[i];
- }
- // cout<<x<<" "<<S<<endl;
- if(S>=m)
- {
- return true;
- }
- return false;
- }
- main()
- {
- freopen("pancake.inp","r",stdin);
- freopen("pancake.out","w",stdout);
- cin>>m>>n;
- for(int i=1;i<=n;i++)
- {
- cin>>t[i];
- }
- long long dau=0,cuoi=t[1]*n;
- long long giua=(dau+cuoi)/2;
- long long ans;
- while(dau<=cuoi)
- {
- int giua=(dau+cuoi)/2;
- if(check(giua)==true)
- {
- ans=giua;
- cuoi=giua-1;
- }
- else
- {
- dau=giua+1;
- }
- }
- cout<<ans;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement