Submission #1115328
Source Code Expand
#include "bits/stdc++.h" using namespace std; #ifdef _DEBUG #include "dump.hpp" #else #define dump(...) #endif #define int long long #define rep(i,a,b) for(int i=(a);i<(b);i++) #define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--) #define all(c) begin(c),end(c) const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f; const int MOD = (int)(1e9) + 7; template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; } template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; } int N, M; bool f(int x) { if (M - (x - N) * 2 >= 2 * x)return false; else return true; } template<class F> int binary_search_(int l, int r, F f) { if (f(l))return l; //exception f(l):true while (l + 1 < r) { int m = (l + r) / 2; if (f(m)) r = m; else l = m; } //f(l):false, f(r):true return r; } signed main() { cin.tie(0); ios::sync_with_stdio(false); cin >> N >> M; int a = binary_search_(N, 1e12 + 1, f); dump(f(a), f(a - 1)); if (f(a) == false)cout << a << endl; else cout << a - 1 << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - Scc Puzzle |
User | minaminao |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1157 Byte |
Status | WA |
Exec Time | 1 ms |
Memory | 256 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 300 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 00_example_01.txt, 00_example_02.txt |
All | 00_example_01.txt, 00_example_02.txt, 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_example_01.txt | AC | 1 ms | 256 KB |
00_example_02.txt | AC | 1 ms | 256 KB |
01.txt | WA | 1 ms | 256 KB |
02.txt | AC | 1 ms | 256 KB |
03.txt | WA | 1 ms | 256 KB |
04.txt | WA | 1 ms | 256 KB |
05.txt | WA | 1 ms | 256 KB |
06.txt | AC | 1 ms | 256 KB |
07.txt | AC | 1 ms | 256 KB |