2
1

More than 3 years have passed since last update.

AtCoder Grand Contest 040 参戦記

Last updated at Posted at 2019-11-03

AtCoder Grand Contest 040 参戦記

AGC040A - Dividing a Strings

25分で突破したが、WA1なので30分扱い.

>< の間は0で、<> の間は、左右の0から1づつインクリメントしてきた大きい方なので、以下みたいに2パスでやれば解ける.

S = input()

N = len(S) + 1
t = [0] * N
for i in range(N - 1):
    if S[i] == '<':
        t[i + 1] = t[i] + 1
for i in range(N - 2, -1, -1):
    if S[i] == '>':
        t[i] = max(t[i], t[i + 1] + 1)
print(sum(t))

AGC040B - Two Contests

全く手付かずで敗退.

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