Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
#include
#include
using namespace std; //DON'T EDIT THIS FUNCTION, AS IT'S HERE TO SUPPORT //THE COMMUNICATION WITH THE INTERACTIVE GRADER int count(string expression) { cout << expression << endl; int matchingRecords; cin >> matchingRecords; return matchingRecords; } //YOUR SOLUTION STARTS HERE string my_to_string(long long x) { string res = ""; while(x > 0) { res += ((x % 10) + '0'); x /= 10; } reverse(res.begin(), res.end()); return res; } int findMoney(int N) { long long L = 0; long long R = 2000000000; while(L <= R) { long long middle = (L + R) / 2; string is_less = "name != bidik || name == bidik && money < "; is_less += my_to_string(middle); string is_equal = "name != bidik || name == bidik && money == "; is_equal += my_to_string(middle); int less = count(is_less); int equal = count(is_equal); if(equal == N) { return middle; } if(less == N) { R = middle; } else { L = middle + 1; } } //make sure this function returns the money donated return 0; } int main(){ int n; cin >> n; cout << findMoney(n) << endl; return 0; }
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)