Last time I'm doing a recent C today
#22
** Thoughts ** ABC160-C I was trying to think about all of $ N! * N $ during the contest, but that would be a TLE. Since we will visit all N, there is a section that does not pass one. If you think of it as clockwise or counterclockwise from $ A_i $, it will not pass either left or right. Therefore, the answer is $ A_i $ and the maximum value of the left and right distances. Note that in the case of $ A_N $ → $ A_1 $, it cannot be calculated as it is, so it was calculated separately.
k, n = map(int,input().split())
a = list(map(int,input().split()))
cost = max(a[0]+k-a[-1],a[-1]-a[-2])
for i in range(1,n-1):
cost = max(a[i]-a[i-1],a[i+1]-a[i],cost)
print(k-cost)
ABC159-C Since the volume is maximum when it is a rectangular parallelepiped, just divide it by 3 and cube it.
print((int(input())/3)**3)
ABC158-C Just calculate. When I solved it last time, I was told that I could turn it for more with a margin, so I calculated up to 10000. It is truncated at // 1.
a, b = map(int,input().split())
for i in range(10000):
if (i * 0.08)//1 == a and (i * 0.1)//1 == b:
print(i)
quit()
print(-1)
ABC157-C When I saw the problem, I thought it was easy, but I couldn't. I couldn't even compare it digit by digit with str. As far as I can see the result, it is not possible to divide the case well. Revenge
ABC156-C Since $ N $ is small, the cost is calculated with all integers less than $ N $. Is it minimal near the median?
n = int(input())
x = list(map(int,input().split()))
ans = 10**9
for i in range(101):
cost = 0
for j in range(n):
cost += (x[j]-i)**2
ans = min(ans,cost)
print(ans)
ABC155-C I put $ S $ in collections.Counter and do most_common to find the mode. All you have to do is output
import collections
n = int(input())
s = [str(input()) for _ in range(n)]
s = collections.Counter(s)
s = s.most_common()
c = s[0][1]
ans = []
for i in range(len(s)):
if s[i][1] == c:
ans.append(s[i][0])
ans.sort()
for i in ans:
print(i)
C is fun. see you
Recommended Posts