fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define ld long double
  5. typedef pair<int,int> pii;
  6. typedef pair<long long ,long long>pll;
  7. #define intmax 100000000
  8. #define se second
  9. #define fi first
  10. #define MOD 1000000007
  11. #define PI 3.1415926535897932385
  12. const long long Nmax=1000000;
  13.  
  14. bool ispossible(ll arr[],ll k,ll n,ll h){
  15. ll temp=0;
  16. for(int i=0;i<n;i++){
  17. temp+=ceil(((long double)arr[i])/k);
  18. }
  19. if(temp<=h)
  20. return true;
  21. return false;
  22. }
  23.  
  24. int main() {
  25. ios_base::sync_with_stdio(false);
  26. cin.tie(NULL);
  27. cout.tie(NULL);
  28.  
  29. int t;
  30. cin>>t;
  31. while(t--){
  32. ll n,h;
  33. cin>>n>>h;
  34. ll arr[n];
  35. ll sum=0;
  36. ll alpha=0;
  37. for(int i=0;i<n;i++){
  38. cin>>arr[i];
  39. sum+=arr[i];
  40. alpha=max(alpha,arr[i]);
  41. }
  42. ll ans=sum+100;
  43. ll l=1;
  44. ll r=alpha;
  45. while(l<=r){
  46. ll mid=(l+r)/2ll;
  47. if(ispossible(arr,mid,n,h)){
  48. ans=min(mid,ans);
  49. r=mid-1;
  50. }
  51. else l=mid+1;
  52. }
  53. cout<<ans<<endl;
  54. }
  55. return 0;
  56. }
  57.  
  58.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Traceback (most recent call last):
  File "/usr/lib/python3.5/py_compile.py", line 125, in compile
    _optimize=optimize)
  File "<frozen importlib._bootstrap_external>", line 735, in source_to_code
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "./prog.py", line 2
    using namespace std;
                  ^
SyntaxError: invalid syntax

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python3.5/py_compile.py", line 129, in compile
    raise py_exc
py_compile.PyCompileError:   File "./prog.py", line 2
    using namespace std;
                  ^
SyntaxError: invalid syntax

stdout
Standard output is empty