Submission #9192722


Source Code Expand

Copy
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
            ∧_∧
      ∧_∧  (´<_` )  Welcome to My Coding Space!
     ( ´_ゝ`) /  ⌒i     @hamayanhamayan0
    /   \     | |
    /   / ̄ ̄ ̄ ̄/  |
  __(__ニつ/     _/ .| .|____
     \/____/ (u ⊃
---------------------------------------------------------------------------------------------------*/














ll N, A, B;
//---------------------------------------------------------------------------------------------------
ll solve(ll a, ll b) {
	ll d = b - a;
	if (d % 2 == 0) return d / 2;

	ll ans = infl;

	// 最左へ
	chmin(ans, a + solve(1, b - a));

	// 最右へ
	chmin(ans, N - b + 1 + solve(a + (N - b + 1), N));

	return ans;
}
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> A >> B;
	cout << solve(A, B) << endl;
}





Submission Info

Submission Time
Task A - Table Tennis Training
User hamayanhamayan
Language C++14 (GCC 5.4.1)
Score 300
Code Size 1810 Byte
Status
Exec Time 1 ms
Memory 256 KB

Judge Result

Set Name Score / Max Score Test Cases
Sample 0 / 0 00-sample-01.txt, 00-sample-02.txt
All 300 / 300 00-sample-01.txt, 00-sample-02.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 01-16.txt, 01-17.txt, 01-18.txt
Case Name Status Exec Time Memory
00-sample-01.txt 1 ms 256 KB
00-sample-02.txt 1 ms 256 KB
01-01.txt 1 ms 256 KB
01-02.txt 1 ms 256 KB
01-03.txt 1 ms 256 KB
01-04.txt 1 ms 256 KB
01-05.txt 1 ms 256 KB
01-06.txt 1 ms 256 KB
01-07.txt 1 ms 256 KB
01-08.txt 1 ms 256 KB
01-09.txt 1 ms 256 KB
01-10.txt 1 ms 256 KB
01-11.txt 1 ms 256 KB
01-12.txt 1 ms 256 KB
01-13.txt 1 ms 256 KB
01-14.txt 1 ms 256 KB
01-15.txt 1 ms 256 KB
01-16.txt 1 ms 256 KB
01-17.txt 1 ms 256 KB
01-18.txt 1 ms 256 KB