AtCoder Beginner Contest 063 Review of past questions

Past questions solved for the first time

Time required

スクリーンショット 2020-01-01 18.54.15.png

Problem A

When I wrote it with the ternary operator, the number of characters was small, so I could type it quickly.

answerA.py


a,b=map(int,input().split())
print(a+b if a+b<10 else "error")

B problem

Whether or not there is a cover is set, the ternary operator is also used here

answerB.py


s=list(input())
t=list(set(s))
print("yes" if len(s)==len(t) else "no")

C problem

Cases are divided according to whether they are multiples of 10, and when there are only multiples of 10, the sum is always a multiple of 10, so 0 is output. If there are things that are not multiples of 10, add them all up and if they are multiples of 10, then they are not multiples of 10. All you have to do is pull the smallest one.

answerC.py


n=int(input())
a=[]
b=[]
for i in range(n):
    s=int(input())
    if s%10==0:
        a.append(s)
    else:
        b.append(s)
b.sort()
if len(b)==0:
    print(0)
else:
    if sum(b)%10==0:
        print(sum(a)+sum(b[1:]))
    else:
        print(sum(a)+sum(b))

D problem

The B problem of the latest AGC041 was a fairly similar problem (typical ??). First of all, ** it is inevitable that repeating the explosion honestly will not be in time for the calculation amount **, so I thought about what would happen if the explosion was repeated $ X $ times. Now, for $ X $ explosions, suppose there are $ m_i $ explosions centered around the $ i $ th monster. At this time, the physical strength of the $ i $ th monster is $ h_i-m_i \ times A- (X-m_i) \ times B = h_i-X \ times B-m_i \ times (AB) $, which is an arbitrary 1 If <= $ i $ <= N is 0 or less, you can defeat all N monsters. Therefore, ** $ (h_i-X \ times B) / (A-B) $ rounded up is the number of explosions around that monster required to defeat each monster **. If this number of times is calculated for each monster and the added value is $ X $ or less, it can be said that all monsters can be erased by x explosions. Also, it is clear from the constraint that ** $ X $ is at most $ 10 ^ 9 $, and it is clear that all monsters can be erased at the boundary of $ X $ **, so the value is calculated by binary search. You can ask for it. From the above, it was found that it can be calculated by a constant multiple (about 10 times) of O (n).

answerD.py


import math
n,a,b=map(int,input().split())
h=[int(input()) for i in range(n)]

def explode(x):
    global n
    c=0
    for i in range(n):
        if h[i]-x*b>0:
            c+=math.ceil((h[i]-x*b)/(a-b))
    return c<=x

l,r=1,10**9
while l+1<r:
    k=(l+r)//2
    if explode(k):
        r=k
    else:
        l=k

print(l if explode(l) else r)

Recommended Posts

AtCoder Beginner Contest 102 Review of past questions
AtCoder Beginner Contest 072 Review of past questions
AtCoder Beginner Contest 085 Review of past questions
AtCoder Beginner Contest 062 Review of past questions
AtCoder Beginner Contest 113 Review of past questions
AtCoder Beginner Contest 074 Review of past questions
AtCoder Beginner Contest 051 Review of past questions
AtCoder Beginner Contest 127 Review of past questions
AtCoder Beginner Contest 119 Review of past questions
AtCoder Beginner Contest 151 Review of past questions
AtCoder Beginner Contest 075 Review of past questions
AtCoder Beginner Contest 054 Review of past questions
AtCoder Beginner Contest 110 Review of past questions
AtCoder Beginner Contest 117 Review of past questions
AtCoder Beginner Contest 070 Review of past questions
AtCoder Beginner Contest 112 Review of past questions
AtCoder Beginner Contest 076 Review of past questions
AtCoder Beginner Contest 089 Review of past questions
AtCoder Beginner Contest 069 Review of past questions
AtCoder Beginner Contest 079 Review of past questions
AtCoder Beginner Contest 067 Review of past questions
AtCoder Beginner Contest 093 Review of past questions
AtCoder Beginner Contest 046 Review of past questions
AtCoder Beginner Contest 123 Review of past questions
AtCoder Beginner Contest 049 Review of past questions
AtCoder Beginner Contest 078 Review of past questions
AtCoder Beginner Contest 081 Review of past questions
AtCoder Beginner Contest 047 Review of past questions
AtCoder Beginner Contest 060 Review of past questions
AtCoder Beginner Contest 104 Review of past questions
AtCoder Beginner Contest 057 Review of past questions
AtCoder Beginner Contest 126 Review of past questions
AtCoder Beginner Contest 090 Review of past questions
AtCoder Beginner Contest 103 Review of past questions
AtCoder Beginner Contest 061 Review of past questions
AtCoder Beginner Contest 059 Review of past questions
AtCoder Beginner Contest 044 Review of past questions
AtCoder Beginner Contest 083 Review of past questions
AtCoder Beginner Contest 048 Review of past questions
AtCoder Beginner Contest 124 Review of past questions
AtCoder Beginner Contest 116 Review of past questions
AtCoder Beginner Contest 097 Review of past questions
AtCoder Beginner Contest 088 Review of past questions
AtCoder Beginner Contest 053 Review of past questions
AtCoder Beginner Contest 094 Review of past questions
AtCoder Beginner Contest 063 Review of past questions
AtCoder Beginner Contest 107 Review of past questions
AtCoder Beginner Contest 071 Review of past questions
AtCoder Beginner Contest 064 Review of past questions
AtCoder Beginner Contest 082 Review of past questions
AtCoder Beginner Contest 084 Review of past questions
AtCoder Beginner Contest 068 Review of past questions
AtCoder Beginner Contest 058 Review of past questions
AtCoder Beginner Contest 043 Review of past questions
AtCoder Beginner Contest 098 Review of past questions
AtCoder Beginner Contest 114 Review of past questions
AtCoder Beginner Contest 045 Review of past questions
AtCoder Beginner Contest 120 Review of past questions
AtCoder Beginner Contest 108 Review of past questions
AtCoder Beginner Contest 106 Review of past questions
AtCoder Beginner Contest 122 Review of past questions