fork download
  1. #include<bits/stdc++.h>
  2. #include<queue>
  3. using namespace std;
  4.  
  5. #define what_is(x) cerr << #x << " is " << x << endl;
  6. #define PI acos(-1)
  7. #define hell 1000000007
  8. #define HELL 998244353
  9. #define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
  10. #define fix(n) cout << fixed << setprecision(n)
  11. #define mset(a,n) memset(a,n,sizeof a)
  12. #define rep(i,a,b) for (__typeof((b)) i=(a);i<(b);i++)
  13. #define repp(i,a,b,p) for(__typeof((b)) i=(a);i<(b);i+=p)
  14. #define ren(i,a,b) for(__typeof((a)) i=(a);i>=(b);i--)
  15. #define renn(i,a,b,p) for(__typeof((a) i=(a);i>=(b);i-=p)
  16. #define ADD(a,b,c) ((a)%c+(b)%c)%c
  17. #define SUB(a,b,c) ((a)%c-(b)%c+c)%c
  18. #define MUL(a,b,c) (((a)%c)*((b)%c))%c
  19. #define lbd lower_bound
  20. #define ubd upper_bound
  21. #define ll long long
  22. #define ld long double
  23. #define pb push_back
  24. #define fi first
  25. #define se second
  26. #define vll vector<ll>
  27. #define pll pair<ll,ll>
  28. #define vpll vector<pll>
  29. #define all(v) (v).begin(), (v).end()
  30. #define sz(x) (ll)x.size()
  31. // #define out(n) cout<<n<<" "
  32. #define outl(n) cout<<n<<endl
  33. #define bug(n) {outl(n);return;}
  34. #define pii pair<int,int>
  35. #define lim 9223372036854775805
  36. #define ninf -9223372036854775802
  37. #define M 10000000009
  38. #define eps 1e-9
  39. #define MAX 10
  40. //#define N 100001
  41. #define db(a) for(auto it:a) {cout<<it<<" ";}cout<<endl;
  42. ll prime[MAX];
  43. ll fact[MAX];
  44.  
  45. const long long INF64 = 1e18;
  46.  
  47.  
  48.  
  49. ll find(vll &a,ll mx){
  50. ll ans=0;
  51. rep(i,0,sz(a)){
  52. ans+=(ll)ceil((1.0*a[i])/(1.0*mx));
  53. ans--;
  54. }
  55. return ans;
  56. }
  57. void solve(ll ttt){
  58. ll n,k;
  59. cin>>n>>k;
  60. vll a(n);
  61. rep(i,0,n)
  62. cin>>a[i];
  63. ll low=0,high=10000000000;
  64. if(k==0){
  65. ll mx=INT_MIN;
  66. rep(i,0,n){
  67. mx=max(mx,a[i]);
  68. }
  69. cout<<mx<<endl;
  70. return ;
  71. }
  72. while(low<high){
  73. ll mid=low+(high-low)/2;
  74.  
  75. ll req_cut=find(a,mid);
  76. //cout<<"For mid = "<<mid<<" cuts req = "<<req_cut<<endl;
  77. if(req_cut>k){
  78. low=mid+1;
  79. }
  80. else
  81. high=mid;
  82. }
  83. cout<<(ll)low<<endl;
  84.  
  85. }
  86. int main(){
  87. io;
  88. // sieve();
  89. // factorial();
  90. #ifndef ONLINE_JUDGE
  91. freopen("input1.txt","r",stdin);
  92. // freopen("output1.txt","w",stdout);
  93. #endif
  94. ll t=1;
  95. //cin>>t;
  96. fix(12);
  97. rep(q,1,t+1){
  98. // cout<<"Case #"<<q<<": ";
  99. solve(q);
  100. //solve2();
  101. }
  102. return 0;
  103.  
  104. }
  105.  
  106.  
  107.  
Success #stdin #stdout 0s 4544KB
stdin
Standard input is empty
stdout
0