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 1 year has passed since last update.

AtCoder Beginner Contest 240 参戦記

Posted at

AtCoder Beginner Contest 240 参戦記

ABC240A - Edge Checker

4分で突破. 書くだけ.

a, b = map(int, input().split())

if (a + 1 == b) or (a == 1 and b == 10):
    print('Yes')
else:
    print('No')

ABC240B - Count Distinct Integers

1分半で突破. 書くだけ. というか、種類数を数える問題何度目だ. 頻出にもほどがある.

N, *a = map(int, open(0).read().split())

print(len(set(a)))

ABC240C - Jumping Takahashi

4分で突破. C問題で DP 出るのかあと思った.

from sys import stdin

readline = stdin.readline

N, X = map(int, readline().split())
t = set([0])
for _ in range(N):
    a, b = map(int, readline().split())
    u = set()
    for x in t:
        u.add(x + a)
        u.add(x + b)
    t = u

if X in t:
    print('Yes')
else:
    print('No')

ABC240D - Strange Balls

9分で突破. 数値と幾つ連続で並んでいるかの2つ組のリストを管理すればいいだけですね.

N, *a = map(int, open(0).read().split())

q = []
c = 0
result = []
for x in a:
    if len(q) == 0 or q[-1][0] != x:
        q.append((x, 1))
        c += 1
    else:
        n = q[-1][1]
        if n == x - 1:
            q.pop()
            c -= n
        else:
            q[-1] = (x, n + 1)
            c += 1
    result.append(c)
print(*result, sep='\n')
0
1
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
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?