fork download
  1. l = 0, h = n-1;
  2. while (h - l > 1) // a.k.a. (h - l) >=2 --> l < (l+h)/2 < h
  3. {
  4. mid = (l+h)/2;
  5. if P(mid) l = mid;
  6. else h = mid;
  7. }
  8. for (i = h; i>=l; i--)
  9. {
  10. if P(i) return i;
  11. }
  12. assert(false);
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:1: error: class, interface, or enum expected
l = 0, h = n-1;
^
Main.java:2: error: class, interface, or enum expected
while (h - l > 1) // a.k.a. (h - l) >=2 --> l < (l+h)/2 < h
^
Main.java:5: error: class, interface, or enum expected
   	if P(mid) l = mid;
   	^
Main.java:6: error: class, interface, or enum expected
   	else h = mid;
   	^
Main.java:7: error: class, interface, or enum expected
}
^
Main.java:8: error: class, interface, or enum expected
for (i = h; i>=l; i--)
            ^
Main.java:8: error: class, interface, or enum expected
for (i = h; i>=l; i--)
                  ^
Main.java:11: error: class, interface, or enum expected
}
^
8 errors
stdout
Standard output is empty