Daily AtCoder # 12 in Python

Introduction

Last time I thought I shouldn't write because there is AGC today, but I couldn't solve a single question, so I'll write it. Recently, I get tired because AGC-A is also recommended.

#12 Problem 1WA. Problems that I participated in but could not solve

** Thoughts ** The first thing to think about is when $ B-A $ is even, and when it is even, $ \ frac {B-A} {2} $ is fine. The problem is when $ B-A $ is odd. When $ B-A $ is odd, no matter how close they are, they cannot be on the same table. So either one has to go to 1 or N to adjust the evenness. Of course, the closer to 1 and N, the less the number of times it takes to get to the same table, so find which is closer with $ min (a-1, n-b) $. The reason for a-1 is that the numbers on the table start from 1. When you go to 1 and N, +1 and $ B-A-1 $ become even numbers to adjust the evenness, so you can do $ \ frac {B-A-1} {2} $.

n, a, b = map(int,input().split())

d = b - a
if d % 2 == 0:
    print(d//2)
else:
    print(min(a-1,n-b)+1+(b-a-1)//2)

Judgment of oddness is made by if, and the rest is calculated as described above.

Summary

AGC-A is difficult. Tomorrow's ABC will aim for A ~ C's three finishes for the time being !! see you. good night.

Recommended Posts

Daily AtCoder # 36 in Python
Daily AtCoder # 2 in Python
Daily AtCoder # 32 in Python
Daily AtCoder # 6 in Python
Daily AtCoder # 18 in Python
Daily AtCoder # 53 in Python
Daily AtCoder # 33 in Python
Daily AtCoder # 7 in Python
Daily AtCoder # 24 in Python
Daily AtCoder # 37 in Python
Daily AtCoder # 8 in Python
Daily AtCoder # 42 in Python
Daily AtCoder # 21 in Python
Daily AtCoder # 17 in Python
Daily AtCoder # 38 in Python
Daily AtCoder # 54 in Python
Daily AtCoder # 11 in Python
Daily AtCoder # 15 in Python
Daily AtCoder # 47 in Python
Daily AtCoder # 45 in Python
Daily AtCoder # 30 in Python
Daily AtCoder # 40 in Python
Daily AtCoder # 10 in Python
Daily AtCoder # 5 in Python
Daily AtCoder # 28 in Python
Daily AtCoder # 39 in Python
Daily AtCoder # 20 in Python
Daily AtCoder # 19 in Python
Daily AtCoder # 14 in Python
Daily AtCoder # 50 in Python
Daily AtCoder # 26 in Python
Daily AtCoder # 4 in Python
Daily AtCoder # 43 in Python
Daily AtCoder # 29 in Python
Daily AtCoder # 22 in Python
Daily AtCoder # 49 in Python
Daily AtCoder # 27 in Python
Daily AtCoder # 1 in Python
Daily AtCoder # 25 in Python
Daily AtCoder # 16 in Python
Daily AtCoder # 12 in Python
Daily AtCoder # 48 in Python
Daily AtCoder # 23 in Python
Daily AtCoder # 34 in Python
Daily AtCoder # 51 in Python
Daily AtCoder # 31 in Python
Daily AtCoder # 46 in Python
Daily AtCoder # 35 in Python
Daily AtCoder # 9 in Python
Daily AtCoder # 44 in Python
Daily AtCoder # 41 in Python
Atcoder ABC164 A-C in Python
atCoder 173 Python
Python Input Note in AtCoder
Atcoder ABC167 A-D in Python
Atcoder ABC165 A-D in Python
Atcoder ABC166 A-E in Python
Atcoder ABC169 A-E in Python
AtCoder ABC177 A-D in python
Solve Atcoder ABC169 A-D in Python
Quadtree in Python --2