fork download
  1. int left=min_diff,right=max_diff,mid;
  2. int gval,slope;
  3. while(left<=right) {
  4. mid=(left+right)/2;
  5. //kurangi semua dengan mid
  6. //monotone decreasing: cari MAXIMUM G(n)
  7. //monotone increasing; cari MINIMUM G(n)
  8. //cari elemen minimum untuk dapat sekian (cnt)
  9. if(cnt<=k) {
  10. slope=mid;
  11. gval=G(opt);
  12. //decreasing: right=mid-1, increasing: left=mid+1
  13. }
  14. else //kebalikan dari sebelumnya
  15. }
  16. cout<<gval+k*slope<<"\n";
  17.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:1:10: error: ‘min_diff’ was not declared in this scope
 int left=min_diff,right=max_diff,mid;
          ^~~~~~~~
prog.cpp:3:1: error: expected unqualified-id before ‘while’
 while(left<=right) {
 ^~~~~
stdout
Standard output is empty