0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

はじめに

前回
今日もCです

#23

ABC154-C
41diff
len(set(A))=len(A)なら全ての要素が異なるので、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
Hをsortする。必殺技は体力が多い順に使った方が攻撃回数は減るので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
そのまま(i,j)の組を全部試すとTLEするので、最小値を更新していく。そうすると$P_j \leq P_i$を満すかどうかを判定できる。

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
正解した問題をboolで管理する。WAは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神。$N\le 8$なので組合せを全列挙する。

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)))

まとめ

まだ解ける。では、また

0
1
7

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?