1
0

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.

AtCoder Beginner Contest 163 参戦記

Last updated at Posted at 2020-04-19

AtCoder Beginner Contest 163 参戦記

ここ最近は上位20%近辺の常連だったが、今回は上位38.4%の位置ということで、unrated で良かった…….

ABC163A - Circle Pond

4分で突破. 書くだけだったけど、問題文が開始から2分以上見えなかったので時間がかかった. 円周の長さの公式くらい覚えてますよね?

from math import pi

R = int(input())

print(2 * pi * R)

ABC163B - Homework

1分半で突破. 書くだけ. 宿題の所要日数を単純に合計して、夏休みの日数と比較するだけ.

N, M = map(int, input().split())
A = list(map(int, input().split()))

a = sum(A)

if a > N:
    print(-1)
else:
    print(N - a)

追記: これでよかったな.

N, M = map(int, input().split())
A = list(map(int, input().split()))

print(max(N - sum(A), -1))

ABC163C - management

7分半で突破. ディクショナリで直接の部下一覧リストを作ったけど、これ無駄に頑張りすぎてるなと今気づいた. 素直にリストに人数だけ足し込むほうが楽じゃん…….

N = int(input())
A = list(map(int, input().split()))

d = {}

for i in range(N - 1):
    if A[i] in d:
        d[A[i]].append(i + 2)
    else:
        d[A[i]] = [i + 2]

for i in range(1, N + 1):
    if i in d:
        print(len(d[i]))
    else:
        print(0)

追記: これでよかった.

N = int(input())
A = list(map(int, input().split()))

result = [0] * N
for a in A:
    result[a - 1] += 1
print('\n'.join(map(str, result)))

ABC163D - Sum of Large Numbers

まさかの敗退. 0 が邪魔すぎた.

追記: なんで私はコンビネーション計算して0が邪魔でダブるって悩んでたんですかね. ほんと馬鹿すぎて困る.

N, K = map(int, input().split())

result = 0
for i in range(K, N + 2):
    # max: N, N -1, ..., N - i + 1
    a = (N + (N - i + 1)) * i // 2
    # min: 0, 1, .., i - 1
    b = (0 + (i - 1)) * i // 2
    result += a - b + 1
    result %= 1000000007
print(result)
1
0
0

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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?