fork download
  1. // ORZVANH14
  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. #include <bits/stdc++.h>
  30.  
  31. using namespace std;
  32.  
  33. #define int long long
  34. #define ld long double
  35. #define pb push_back
  36. #define fi first
  37. #define se second
  38. #define nn '\n'
  39. #define pi pair<ll,ll>
  40. #define unmp unordered_map
  41. #define uns unordered_set
  42. #define lb lower_bound
  43. #define ub upper_bound
  44. #define pq priority_queue
  45. #define q queue
  46. #define faster ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  47. #define TASK " "
  48. int mod = 1e9+7;
  49. const int N = 2*1e5 + 5;
  50. int MOD = 998244353;
  51. int bit[200000];
  52. int n, t;
  53. int a[N];
  54. bool anhphucbell(int mid, int n){
  55. int hehe = 0;
  56. for(int i = 1; i <= n; i++){
  57. hehe += mid / a[i];
  58. if(hehe >= t) return true;
  59. }
  60. return hehe >= t;
  61. }
  62. signed main(){
  63. ios_base::sync_with_stdio(0);
  64. cin.tie(0);
  65. cout.tie(0);
  66. if(fopen(TASK".INP","r")){
  67. freopen(TASK".INP","r",stdin);
  68. freopen(TASK".OUT","w",stdout);
  69. }
  70. cin >> n >> t;
  71. for(int i = 1; i <= n; i++){
  72. cin >> a[i];
  73. }
  74. int l = 1, r = 1e18, kq = -1;
  75. while(l <= r){
  76. int mid = (l + r) / 2;
  77. if(anhphucbell(mid, n)){
  78. kq = mid;
  79. r = mid - 1;
  80. }
  81. else{
  82. l = mid + 1;
  83. }
  84.  
  85. }
  86. cout << kq << nn;
  87. return 0;
  88. }
  89.  
Success #stdin #stdout 0s 5312KB
stdin
Standard input is empty
stdout
1