[PYTHON] Competitive Pro Debut Senki AtCorder Beginner Contest 160

Debut match ~ AtCorder Beginner Contest 160 ~

It's been a year since I worked as a data scientist, and I wanted to objectively know my coding ability, so I challenged AtCorder.

Even so, I can't participate in SAS, which I usually use in my work, so I'll take a quick look at the Python grammar that I used to touch, learn how to use AtCorder, and prepare an environment where I can test with vscode.

For the time being, I wish I could finish about 3!

See the link below for the actual problem https://atcoder.jp/contests/abc160/tasks

A - Coffee The problem of determining if a given length 6 lowercase letter is similar to coffee. It seems to be a problem of instant killing from a person who has experience in competition professionals, but since the basics of extracting character strings one by one were neglected, this problem digested for 9 minutes (crying)

N = input()
if N[2] == N[3] and N[4] == N[5]:
    print("Yes")
else:
    print("No")

B - Golden Coins A classic problem at the beginning of At Corder dealing with currency exchange. There is no particular problem if I / O of numerical variables and four arithmetic operations can be dropped into the code. However, even with this problem, it took 10 minutes. I have too little sense of variable names (laughs)

N = int(input())
ppp = N // 500
NN = N-500*ppp
pp = NN //5
ans = 1000*ppp+5*pp
print(ans)

C - Traveling Salesman around Lake From here on, I personally have a mountain C problem For the AB problem, I should have just put the question content into the code, It's a little troublesome because I can't do that from the C problem.

This time the problem of finding the shortest path to visit all the houses standing around the pond The process itself came up immediately, but it is another matter whether it can be implemented (crying)

Wrong code submitted ⬇︎

K, N = map(int, input().split())
arr = list(map(int, input().split()))
for i in range(N-2):
    sa =int(arr[i+1]-arr[i])
    ssa =int(arr[i+2]-arr[i+1])
    max_num = max(sa,ssa)
 
hasi = K-arr[N-1]+arr[0]
ans =K-(max(max_num,hasi))
print(ans)

Since I came up with a method (super basic) to loop the processing of List.append I managed to complete it within the time limit !! (80 minutes have passed at this point)

I didn't get an error, so it took a long time to debug. By the way, this problem seems to be fairly easy for a C problem. ⬇︎ Passed code

K, N = map(int, input().split())
arr = list(map(int, input().split()))
List=[]
for i in range(N-1):
    sa =int(arr[i+1]-arr[i])
    List.append(sa)
 
max_num = max(List)
hasi = K-arr[N-1]+arr[0]
PPP = (max(max_num,hasi))
ans = K-PPP
print(ans)

D - Line++

It was a problem that somehow a graph or the shortest path came out. It's not a problem that can be solved in 15 minutes remaining, so give up here By the way, it seems that a friend of a web engineer has solved it.

result

スクリーンショット 2020-04-04 11.27.02.png

7167th out of 9767 people, I think it was a good fight for the debut match (laugh) However, the rating does not go up more than I expected. I have some time in Corona, so let's get serious about it for a while !!

Recommended Posts

Competitive Pro Debut Senki AtCorder Beginner Contest 160
AtCoder Beginner Contest 177
AtCoder Beginner Contest 179
AtCoder Beginner Contest 172
AtCoder Beginner Contest 180
AtCoder Beginner Contest 173
Atcoder Beginner Contest 153
AtCoder Beginner Contest 152 Review
AtCoder Beginner Contest 181 Note
AtCoder Beginner Contest 187 Note
AtCoder Beginner Contest 160 Review
AtCoder Beginner Contest 178 Review
AtCoder Beginner Contest 180 Note
ACL Beginner Contest Note
AtCoder Beginner Contest 166 Review
AtCoder Beginner Contest 167 Review
AtCoder Beginner Contest 182 Note
Competitive Pro Template (Python)
AtCoder Beginner Contest 164 Review
AtCoder Beginner Contest 169 Review
AtCoder Beginner Contest 181 Review
AtCoder Beginner Contest 171 Review
AtCoder Beginner Contest 182 Review
AtCoder Beginner Contest 180 Review
AtCoder Beginner Contest 156 WriteUp
AtCoder Beginner Contest 177 Review
AtCoder Beginner Contest 168 Review
AtCoder Beginner Contest 179 Review
Solve AtCoder Beginner Contest 100-102
AtCoder Beginner Contest 167 Memorandum
AtCoder Beginner Contest 172 Review
AtCoder Beginner Contest 183 Note
AtCoder Beginner Contest 176 Review
AtCoder Beginner Contest 184 Note
AtCoder Beginner Contest 175 Review
AtCoder Beginner Contest 174 Review
AtCoder Beginner Contest 153 Review
AtCoder Beginner Contest 156 Review
AtCoder Beginner Contest 161 Review
AtCoder Beginner Contest 170 Review
AtCoder Beginner Contest 165 Review
AtCoder Beginner Contest 173 Review
AtCoder Beginner Contest 188 Note
AtCoder Beginner Contest 155 Review
AtCoder Beginner Contest 162 Review