fork download
  1. #include <bits/stdc++.h>
  2. #define int long long
  3. #define endl '\n'
  4. #define Deghish ios_base::sync_with_stdio(false);cin.tie(NULL);
  5. using namespace std;
  6. void solve() {
  7. int n,t;cin>>n>>t;
  8. vector<int>a(n);
  9. int l=1,h=1e9;
  10. for (auto &i:a)cin>>i;
  11. int ans=0;
  12. while (l<=h) {
  13. int mid=l+(h-l)/2;
  14. int x=0;
  15. for (auto i:a) {
  16. x+=mid/i;
  17. }
  18. if (x>=t) {
  19. ans=mid;
  20. h=mid-1;
  21. }
  22. else l=mid+1;
  23.  
  24. }
  25. cout<<ans;
  26. }
  27. signed main() {
  28. Deghish
  29. int Tc = 1;//cin >> Tc;
  30. while (Tc--) {
  31. solve();
  32. }
  33. return 0;
  34. }
  35.  
  36.  
Success #stdin #stdout 0s 5332KB
stdin
3 7
3 2 5
stdout
8