Last time Today is also C
#23 ABC154-C 41diff If len (set (A)) = len (A), all the elements are different, so just set
n = int(input())
a = list(map(int,input().split()))
a_s = set(a)
if len(a) == len(a_s):
print('YES')
else:
print('NO')
ABC153-C 36diff Sort H. Since the number of attacks will decrease if you use the special move in descending order of physical strength, add from H [k:]
n, k = map(int,input().split())
h = list(map(int,input().split()))
h.sort(reverse=True)
ans = 0
for i in range(k,n):
ans += h[i]
print(ans)
ABC152-C 119diff If you try all the (i, j) pairs as it is, it will be TLE, so update the minimum value. Then you can determine if $ P_j \ leq P_i $ is satisfied.
n = int(input())
p = list(map(int,input().split()))
ans = 0
for i in range(n):
if i == 0:
ans += 1
m = p[0]
continue
if p[i] <= m:
ans += 1
m = p[i]
print(ans)
ABC151-C 239diff Manage the correct questions with bool. WA is just added when AC.
n, m = map(int,input().split())
ps = list(list(map(str,input().split())) for _ in range(m))
check = [True] * (n+1)
wa = [0] * (n+1)
wa_ans = 0
for i in range(m):
if ps[i][1] == 'AC' and check[int(ps[i][0])]:
check[int(ps[i][0])] = False
wa_ans += wa[int(ps[i][0])]
if ps[i][1] == 'WA':
wa[int(ps[i][0])] += 1
ans = 0
for i in check:
if not i:
ans += 1
print(ans,wa_ans)
ABC150-C 94diff itertools god. Since it is $ N \ le 8 $, all combinations are listed.
import itertools
n = int(input())
p = tuple(((map(int,input().split()))))
q = tuple(((map(int,input().split()))))
num = []
for i in range(1,n+1):
num.append(i)
ans = []
for i in itertools.permutations(num,n):
ans.append(i)
print(abs(ans.index(p)-ans.index(q)))
I can still solve it. see you
Recommended Posts