Precreation contest files
This commit is contained in:
30
misc/others/lares.cpp
Normal file
30
misc/others/lares.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int m, n, k;
|
||||
int check(int _x) {
|
||||
int mn = _x * 2;
|
||||
int nn = _x;
|
||||
if (mn < 0 || nn < 0 || m - mn + n - nn < k) {
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int main() {
|
||||
cin >> m >> n >> k;
|
||||
int l = 0, r = min(m / 2, n);
|
||||
|
||||
int res = 0;
|
||||
while (l < r) {
|
||||
int mid = (l + r) / 2;
|
||||
if (check(mid)) {
|
||||
res = max(res, mid);
|
||||
l = mid + 1;
|
||||
} else {
|
||||
r = mid;
|
||||
}
|
||||
}
|
||||
cout << res << '\n';
|
||||
}
|
||||
Reference in New Issue
Block a user