Submission #1115332
Source Code Expand
#include <bits/stdc++.h> using namespace std; #define FOR(i,a,b) for (int i = (a); i < (b); i++) #define RFOR(i,b,a) for (int i = (b) - 1; i >= (a); i--) #define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++) #define FILL(a,value) memset(a, value, sizeof(a)); #define SZ(a) (int)a.size() #define ALL(a) a.begin(), a.end() #define PB push_back #define MP make_pair typedef long long LL; typedef vector<int> VI; typedef pair<int, int> PII; const long double PI = acos(-1.0); const int INF = 1000 * 1000 * 1000 + 7; const LL LINF = INF * (LL) INF; LL a,b; bool ok(LL x) { if(x>2*b)return 0; LL w = b-x; LL aa = a+w/2; // cerr<<aa<<endl; return aa>=x; } int main() { //freopen("in.txt", "r", stdin); ios::sync_with_stdio(0);cin.tie(0); cin>>a>>b; b/=2; LL d = max(0ll,(b-a)/2); cout<<min(a+d,b); return 0; cerr<<ok(234530); return 0; LL l=0,r=1000000000005ll; while(l+1<r) { LL x = (l+r)/2; if(ok(x)) { l=x; }else { r=x; } } cout<<l; }
Submission Info
Submission Time | |
---|---|
Task | C - Scc Puzzle |
User | felix13 |
Language | C++14 (GCC 5.4.1) |
Score | 300 |
Code Size | 1064 Byte |
Status | AC |
Exec Time | 1 ms |
Memory | 256 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 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 | AC | 1 ms | 256 KB |
02.txt | AC | 1 ms | 256 KB |
03.txt | AC | 1 ms | 256 KB |
04.txt | AC | 1 ms | 256 KB |
05.txt | AC | 1 ms | 256 KB |
06.txt | AC | 1 ms | 256 KB |
07.txt | AC | 1 ms | 256 KB |