int left= min_diff,right= max_diff,mid;
int gval,slope;
while ( left<= right) {
mid= ( left+ right) / 2 ;
//kurangi semua dengan mid
//monotone decreasing: cari MAXIMUM G(n)
//monotone increasing; cari MINIMUM G(n)
//cari elemen minimum untuk dapat sekian (cnt)
if ( cnt<= k) {
slope= mid;
gval= G( opt) ;
//decreasing: right=mid-1, increasing: left=mid+1
}
else //kebalikan dari sebelumnya
}
cout << gval+ k* slope<< "\n " ;
aW50IGxlZnQ9bWluX2RpZmYscmlnaHQ9bWF4X2RpZmYsbWlkOwppbnQgZ3ZhbCxzbG9wZTsKd2hpbGUobGVmdDw9cmlnaHQpIHsKCW1pZD0obGVmdCtyaWdodCkvMjsKCS8va3VyYW5naSBzZW11YSBkZW5nYW4gbWlkCgkvL21vbm90b25lIGRlY3JlYXNpbmc6IGNhcmkgTUFYSU1VTSBHKG4pCgkvL21vbm90b25lIGluY3JlYXNpbmc7IGNhcmkgTUlOSU1VTSBHKG4pCgkvL2NhcmkgZWxlbWVuIG1pbmltdW0gdW50dWsgZGFwYXQgc2VraWFuIChjbnQpCglpZihjbnQ8PWspIHsKCQlzbG9wZT1taWQ7CgkJZ3ZhbD1HKG9wdCk7CgkJLy9kZWNyZWFzaW5nOiByaWdodD1taWQtMSwgaW5jcmVhc2luZzogbGVmdD1taWQrMQoJfQoJZWxzZQkvL2tlYmFsaWthbiBkYXJpIHNlYmVsdW1ueWEKfQpjb3V0PDxndmFsK2sqc2xvcGU8PCJcbiI7Cg==
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