fork download
  1. class Solution {
  2. public:
  3. typedef long long ll;
  4.  
  5. long long minNumberOfSeconds(int h, vector<int>& v) {
  6. ll i,n=(ll)v.size(),l,r,mid,md=1e8,mx,x,val,tmes=80;
  7. map<ll,ll> mp;
  8.  
  9. mx=(ll)md*md;
  10. l=0;r=mx;
  11.  
  12. for(i=0;i<100001;i++) mp[i*(i+1)/2]=i;
  13.  
  14. while(l<r){
  15. mid=(l+r)/2;
  16. val=0;
  17.  
  18. for(i=0;i<n;i++){
  19. x=mid/v[i];
  20. auto it= mp.upper_bound(x);
  21. it--;
  22. val+=it->second;
  23. }
  24.  
  25. if(val>=h) r=mid;
  26. else l=mid+1;
  27. }
  28.  
  29. mid=(l+r)/2;
  30.  
  31. return mid;
  32.  
  33. }
  34. };
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:5:41: error: ‘vector’ has not been declared
     long long minNumberOfSeconds(int h, vector<int>& v) {
                                         ^~~~~~
prog.cpp:5:47: error: expected ‘,’ or ‘...’ before ‘<’ token
     long long minNumberOfSeconds(int h, vector<int>& v) {
                                               ^
prog.cpp: In member function ‘long long int Solution::minNumberOfSeconds(int, int)’:
prog.cpp:6:20: error: ‘v’ was not declared in this scope
         ll i,n=(ll)v.size(),l,r,mid,md=1e8,mx,x,val,tmes=80;
                    ^
prog.cpp:7:9: error: ‘map’ was not declared in this scope
         map<ll,ll> mp;
         ^~~
prog.cpp:7:15: error: expected primary-expression before ‘,’ token
         map<ll,ll> mp;
               ^
prog.cpp:7:18: error: expected primary-expression before ‘>’ token
         map<ll,ll> mp;
                  ^
prog.cpp:7:20: error: ‘mp’ was not declared in this scope
         map<ll,ll> mp;
                    ^~
prog.cpp:9:9: error: ‘mx’ was not declared in this scope
         mx=(ll)md*md;
         ^~
prog.cpp:9:16: error: ‘md’ was not declared in this scope
         mx=(ll)md*md;
                ^~
prog.cpp:10:9: error: ‘l’ was not declared in this scope
         l=0;r=mx;
         ^
prog.cpp:10:9: note: suggested alternative: ‘ll’
         l=0;r=mx;
         ^
         ll
prog.cpp:10:13: error: ‘r’ was not declared in this scope
         l=0;r=mx;
             ^
prog.cpp:15:13: error: ‘mid’ was not declared in this scope
             mid=(l+r)/2;
             ^~~
prog.cpp:16:13: error: ‘val’ was not declared in this scope
             val=0;
             ^~~
prog.cpp:19:17: error: ‘x’ was not declared in this scope
                 x=mid/v[i];
                 ^
prog.cpp:29:9: error: ‘mid’ was not declared in this scope
         mid=(l+r)/2;
         ^~~
stdout
Standard output is empty