s_id
stringlengths
10
10
p_id
stringlengths
6
6
u_id
stringlengths
10
10
date
stringlengths
10
10
language
stringclasses
1 value
original_language
stringclasses
11 values
filename_ext
stringclasses
1 value
status
stringclasses
1 value
cpu_time
int64
0
100
memory
stringlengths
4
6
code_size
int64
15
14.7k
code
stringlengths
15
14.7k
problem_id
stringlengths
6
6
problem_description
stringlengths
358
9.83k
input
stringlengths
2
4.87k
output
stringclasses
807 values
__index_level_0__
int64
1.1k
1.22M
s624511984
p01810
u835414158
1517900261
Python
Python
py
Accepted
40
7704
89
b, k = map(int, raw_input().split()) g=0 for i in range(0,b-1): g=1+(k*g)/(k-1) print g
p01810
<h2>監獄</h2> <p>無限人の囚人たちがいる。はじめ、囚人たちは <var>0, 1, 2,</var> ... と番号が振られている。</p> <p>次の操作を <var>N</var> 回行う。</p> <ul> <li><var>0</var> 番目の囚人を釈放し、<var>k, 2k, 3k,</var> ... 番目の囚人たちを処刑する。</li> <li>その後、残った囚人たちに番号を振り直す。このとき、元の番号が小さい囚人から順に <var>0, 1, 2, </var> ... と番号を振る。</li> </ul> <p><var>N</var> 回目の操作で釈放される囚人がはじめに振られていた番...
4 2
7
27,048
s599967124
p01810
u509278866
1530006844
Python
Python3
py
Accepted
90
9020
796
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools sys.setrecursionlimit(10**7) inf = 10**20 eps = 1.0 / 10**10 mod = 10**9+7 dd = [(0,-1),(1,0),(0,1),(-1,0)] ddn = [(0,-1),(1,-1),(1,0),(1,1),(0,1),(-1,-1),(-1,0),(-1,1)] def LI(): return [int(x) for x in sys.stdin....
p01810
<h2>監獄</h2> <p>無限人の囚人たちがいる。はじめ、囚人たちは <var>0, 1, 2,</var> ... と番号が振られている。</p> <p>次の操作を <var>N</var> 回行う。</p> <ul> <li><var>0</var> 番目の囚人を釈放し、<var>k, 2k, 3k,</var> ... 番目の囚人たちを処刑する。</li> <li>その後、残った囚人たちに番号を振り直す。このとき、元の番号が小さい囚人から順に <var>0, 1, 2, </var> ... と番号を振る。</li> </ul> <p><var>N</var> 回目の操作で釈放される囚人がはじめに振られていた番...
4 2
7
27,049
s404489279
p01810
u919638656
1562762725
Python
Python3
py
Accepted
70
5596
113
n, k = map(int,input().split()) now = 0 while n > 1: n -= 1 now = (now * k) // (k - 1) + 1 print(now)
p01810
<h2>監獄</h2> <p>無限人の囚人たちがいる。はじめ、囚人たちは <var>0, 1, 2,</var> ... と番号が振られている。</p> <p>次の操作を <var>N</var> 回行う。</p> <ul> <li><var>0</var> 番目の囚人を釈放し、<var>k, 2k, 3k,</var> ... 番目の囚人たちを処刑する。</li> <li>その後、残った囚人たちに番号を振り直す。このとき、元の番号が小さい囚人から順に <var>0, 1, 2, </var> ... と番号を振る。</li> </ul> <p><var>N</var> 回目の操作で釈放される囚人がはじめに振られていた番...
4 2
7
27,050
s578093662
p01810
u191474223
1562726116
Python
Python3
py
Accepted
70
5596
103
N,K = map(int, input().split()) ans = 1 for _ in range(N-1): ans += (ans+K-2)//(K-1) print(ans-1)
p01810
<h2>監獄</h2> <p>無限人の囚人たちがいる。はじめ、囚人たちは <var>0, 1, 2,</var> ... と番号が振られている。</p> <p>次の操作を <var>N</var> 回行う。</p> <ul> <li><var>0</var> 番目の囚人を釈放し、<var>k, 2k, 3k,</var> ... 番目の囚人たちを処刑する。</li> <li>その後、残った囚人たちに番号を振り直す。このとき、元の番号が小さい囚人から順に <var>0, 1, 2, </var> ... と番号を振る。</li> </ul> <p><var>N</var> 回目の操作で釈放される囚人がはじめに振られていた番...
4 2
7
27,051
s323159576
p01810
u171377572
1526527769
Python
Python3
py
Accepted
60
5604
120
N, k = [int(i) for i in input().split()] ans = 0 for i in range(N - 1): ans = (ans * k + k - 1) // (k - 1) print(ans)
p01810
<h2>監獄</h2> <p>無限人の囚人たちがいる。はじめ、囚人たちは <var>0, 1, 2,</var> ... と番号が振られている。</p> <p>次の操作を <var>N</var> 回行う。</p> <ul> <li><var>0</var> 番目の囚人を釈放し、<var>k, 2k, 3k,</var> ... 番目の囚人たちを処刑する。</li> <li>その後、残った囚人たちに番号を振り直す。このとき、元の番号が小さい囚人から順に <var>0, 1, 2, </var> ... と番号を振る。</li> </ul> <p><var>N</var> 回目の操作で釈放される囚人がはじめに振られていた番...
4 2
7
27,052
s182535582
p01810
u281836941
1513700729
Python
Python3
py
Accepted
100
5604
445
def horizontal_input(T=str): return list(map(T,input().split())) def vertical_input(n,T=str,sep=False,septype=tuple): data=[] if sep: for i in range(n): data.append(septype(map(T,input().split()))) else: for i in range(n): data.append(T(input())) return data ...
p01810
<h2>監獄</h2> <p>無限人の囚人たちがいる。はじめ、囚人たちは <var>0, 1, 2,</var> ... と番号が振られている。</p> <p>次の操作を <var>N</var> 回行う。</p> <ul> <li><var>0</var> 番目の囚人を釈放し、<var>k, 2k, 3k,</var> ... 番目の囚人たちを処刑する。</li> <li>その後、残った囚人たちに番号を振り直す。このとき、元の番号が小さい囚人から順に <var>0, 1, 2, </var> ... と番号を振る。</li> </ul> <p><var>N</var> 回目の操作で釈放される囚人がはじめに振られていた番...
4 2
7
27,053
s902180400
p01811
u999854911
1489919229
Python
Python3
py
Accepted
100
7584
751
# Str -> Bool def solve(s): if len(s) < 3: return False history = [] t = s while t.find("ABC") != -1: if t[0:3] == "ABC": t = t.replace("ABC", "A") history.append("A") elif t[-3:] == "ABC": t = t.replace("ABC", "C") history.append...
p01811
<h2>ABC Gene</h2> <p>文字列 <code>ABC</code> で表される遺伝子配列がある。あなたは次の操作を何回か行い、この遺伝子配列を書き換えていくことができる。</p> <ul> <li>文字 <code>A</code>,<code>B</code>,<code>C</code> のうち <var>1</var> つを選ぶ。これを <var>x</var> とおく。遺伝子配列に含まれるすべての <var>x</var> をそれぞれ <code>ABC</code> へ同時に置き換える。</li> </ul> <p><code>A</code>,<code>B</code>,<code>C</co...
ABC
Yes
27,054
s376815858
p01811
u942982291
1508395841
Python
Python
py
Accepted
90
6484
375
#!/usr/bin/python if __name__ == "__main__": S = raw_input() c = ['A','B','C'] while True: if len(S) <= 3: print "Yes" if S == "ABC" else "No" break T = S.strip().split("ABC") if len(T) == 1: print "No" break P = ''.join(T) cnt = 0 for x in c: if x in P: cnt += 1 else: ...
p01811
<h2>ABC Gene</h2> <p>文字列 <code>ABC</code> で表される遺伝子配列がある。あなたは次の操作を何回か行い、この遺伝子配列を書き換えていくことができる。</p> <ul> <li>文字 <code>A</code>,<code>B</code>,<code>C</code> のうち <var>1</var> つを選ぶ。これを <var>x</var> とおく。遺伝子配列に含まれるすべての <var>x</var> をそれぞれ <code>ABC</code> へ同時に置き換える。</li> </ul> <p><code>A</code>,<code>B</code>,<code>C</co...
ABC
Yes
27,055
s114258485
p01811
u942982291
1508396162
Python
Python
py
Accepted
30
6480
351
#!/usr/bin/python if __name__ == "__main__": S = raw_input() c = ['A','B','C'] while True: if len(S) <= 3: print "Yes" if S == "ABC" else "No" break T = S.strip().split("ABC") P = ''.join(T) cnt = 0 for x in c: if x in P: cnt += 1 else: S = x.join(T) if len(T) == 1 or c...
p01811
<h2>ABC Gene</h2> <p>文字列 <code>ABC</code> で表される遺伝子配列がある。あなたは次の操作を何回か行い、この遺伝子配列を書き換えていくことができる。</p> <ul> <li>文字 <code>A</code>,<code>B</code>,<code>C</code> のうち <var>1</var> つを選ぶ。これを <var>x</var> とおく。遺伝子配列に含まれるすべての <var>x</var> をそれぞれ <code>ABC</code> へ同時に置き換える。</li> </ul> <p><code>A</code>,<code>B</code>,<code>C</co...
ABC
Yes
27,056
s972883645
p01811
u509278866
1530004974
Python
Python3
py
Accepted
80
24560
1,134
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools sys.setrecursionlimit(10**7) inf = 10**20 eps = 1.0 / 10**10 mod = 10**9+7 dd = [(0,-1),(1,0),(0,1),(-1,0)] ddn = [(0,-1),(1,-1),(1,0),(1,1),(0,1),(-1,-1),(-1,0),(-1,1)] def LI(): return [int(x) for x in sys.stdin....
p01811
<h2>ABC Gene</h2> <p>文字列 <code>ABC</code> で表される遺伝子配列がある。あなたは次の操作を何回か行い、この遺伝子配列を書き換えていくことができる。</p> <ul> <li>文字 <code>A</code>,<code>B</code>,<code>C</code> のうち <var>1</var> つを選ぶ。これを <var>x</var> とおく。遺伝子配列に含まれるすべての <var>x</var> をそれぞれ <code>ABC</code> へ同時に置き換える。</li> </ul> <p><code>A</code>,<code>B</code>,<code>C</co...
ABC
Yes
27,057
s373605917
p01811
u352394527
1530359615
Python
Python3
py
Accepted
50
5568
276
s = input() end = "ABC" while True: if s == end: print("Yes") break s = s.replace("ABC", "X") if ("X" not in s) or ("A" in s) + ("B" in s) + ("C" in s) != 2: print("No") break for c in "ABC": if c not in s: s = s.replace("X", c) break
p01811
<h2>ABC Gene</h2> <p>文字列 <code>ABC</code> で表される遺伝子配列がある。あなたは次の操作を何回か行い、この遺伝子配列を書き換えていくことができる。</p> <ul> <li>文字 <code>A</code>,<code>B</code>,<code>C</code> のうち <var>1</var> つを選ぶ。これを <var>x</var> とおく。遺伝子配列に含まれるすべての <var>x</var> をそれぞれ <code>ABC</code> へ同時に置き換える。</li> </ul> <p><code>A</code>,<code>B</code>,<code>C</co...
ABC
Yes
27,058
s343174356
p01811
u352394527
1530359787
Python
Python3
py
Accepted
60
5580
261
s = input() end = "ABC" while True: if s == end: print("Yes") break s = s.replace(end, "X") if ("X" not in s) or sum((c in s for c in end)) != 2: print("No") break for c in end: if c not in s: s = s.replace("X", c) break
p01811
<h2>ABC Gene</h2> <p>文字列 <code>ABC</code> で表される遺伝子配列がある。あなたは次の操作を何回か行い、この遺伝子配列を書き換えていくことができる。</p> <ul> <li>文字 <code>A</code>,<code>B</code>,<code>C</code> のうち <var>1</var> つを選ぶ。これを <var>x</var> とおく。遺伝子配列に含まれるすべての <var>x</var> をそれぞれ <code>ABC</code> へ同時に置き換える。</li> </ul> <p><code>A</code>,<code>B</code>,<code>C</co...
ABC
Yes
27,059
s632013434
p01811
u252700163
1532527390
Python
Python3
py
Accepted
50
5564
276
s = input() end = "ABC" while True: if s == end: print("Yes") break s = s.replace("ABC", "X") if ("X" not in s) or ("A" in s) + ("B" in s) + ("C" in s) != 2: print("No") break for c in "ABC": if c not in s: s = s.replace("X", c) break
p01811
<h2>ABC Gene</h2> <p>文字列 <code>ABC</code> で表される遺伝子配列がある。あなたは次の操作を何回か行い、この遺伝子配列を書き換えていくことができる。</p> <ul> <li>文字 <code>A</code>,<code>B</code>,<code>C</code> のうち <var>1</var> つを選ぶ。これを <var>x</var> とおく。遺伝子配列に含まれるすべての <var>x</var> をそれぞれ <code>ABC</code> へ同時に置き換える。</li> </ul> <p><code>A</code>,<code>B</code>,<code>C</co...
ABC
Yes
27,060
s882934294
p01811
u855199458
1530721949
Python
Python3
py
Accepted
60
5964
311
from collections import deque S = input() Q = deque([S]) while Q: s = Q.pop() if s == "ABC": print("Yes") break s = s.replace("ABC", "x") if not "x" in s: continue for y in "ABC": if not y in s: Q.append(s.replace("x", y)) else: print("No")
p01811
<h2>ABC Gene</h2> <p>文字列 <code>ABC</code> で表される遺伝子配列がある。あなたは次の操作を何回か行い、この遺伝子配列を書き換えていくことができる。</p> <ul> <li>文字 <code>A</code>,<code>B</code>,<code>C</code> のうち <var>1</var> つを選ぶ。これを <var>x</var> とおく。遺伝子配列に含まれるすべての <var>x</var> をそれぞれ <code>ABC</code> へ同時に置き換える。</li> </ul> <p><code>A</code>,<code>B</code>,<code>C</co...
ABC
Yes
27,061
s260096089
p01811
u281836941
1514873841
Python
Python3
py
Accepted
50
5604
532
# coding: utf-8 moto=input() s=moto gene='ABC' f=True log=[] while len(s)>3 and f: f=False if s[:3]=='ABC': s=s.replace('ABC','A') log.append('A') f=True elif s[len(s)-3:]=='ABC': s=s.replace('ABC','C') log.append('C') f=True elif 'ABC' in s: s=s.r...
p01811
<h2>ABC Gene</h2> <p>文字列 <code>ABC</code> で表される遺伝子配列がある。あなたは次の操作を何回か行い、この遺伝子配列を書き換えていくことができる。</p> <ul> <li>文字 <code>A</code>,<code>B</code>,<code>C</code> のうち <var>1</var> つを選ぶ。これを <var>x</var> とおく。遺伝子配列に含まれるすべての <var>x</var> をそれぞれ <code>ABC</code> へ同時に置き換える。</li> </ul> <p><code>A</code>,<code>B</code>,<code>C</co...
ABC
Yes
27,062
s622976493
p01821
u260980560
1584785138
Python
Python3
py
Accepted
20
7260
1,024
N = int(input()) def gcd(m, n): while n: m, n = n, m % n return m def lcm(m, n): return m // gcd(m, n) * n def carmichael(x): r = 1 b = 0 while x & 1 == 0: b += 1 x >>= 1 if b > 1: r = 2 if b == 2 else 2**(b-2) y = 3 while y*y <= x: if x % y...
p01821
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type='text/javascript' src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script> </script> <h2>Problem D: Identity Function...
3
1
27,063
s356310067
p01824
u853158149
1560505395
Python
Python3
py
Accepted
90
9596
4,091
#!usr/bin/env python3 from collections import defaultdict from collections import deque from heapq import heappush, heappop import sys import math import bisect import random def LI(): return list(map(int, sys.stdin.readline().split())) def I(): return int(sys.stdin.readline()) def LS():return list(map(list, sys.stdin....
p01824
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type='text/javascript' src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script> </script> <h2>Problem G: Surface Area of Cu...
2 2 2 1 0 0 0
24
27,064
s170789574
p01828
u467175809
1531747254
Python
Python
py
Accepted
10
5036
508
#!/usr/bin/env python import sys import math import itertools as it from collections import deque sys.setrecursionlimit(10000000) S_ = raw_input() T_ = raw_input() + " " S1 = S2 = '' for i in range(len(S_)): if i % 2 == 0: S1 += S_[i] else: S2 += S_[i] for S in [S1, S2]: T = T_ for ...
p01828
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type='text/javascript' src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script> </script> <h2>M and A</h2> <p> The CEO of th...
acmicpc tsukuba
No
27,065
s567918893
p01828
u078042885
1487531207
Python
Python3
py
Accepted
20
7556
179
def f(s,t): j=0;i=0 while i<len(t) and j<len(s): if t[i]==s[j]:j+=2 i+=1 return j>=len(s) I=input s=I() t=I() print(['No','Yes'][f(s,t) or f(s[1:],t)])
p01828
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type='text/javascript' src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script> </script> <h2>M and A</h2> <p> The CEO of th...
acmicpc tsukuba
No
27,066
s488615573
p01828
u506554532
1514535668
Python
Python3
py
Accepted
20
5568
265
def judge(s): if len(s) == 0: return True si = 0 for t in T: if t == s[si]: si += 1 if si == len(s): return True return False S,T = input(),input() N = len(S) print('Yes' if judge(S[::2]) or judge(S[1::2]) else 'No')
p01828
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type='text/javascript' src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script> </script> <h2>M and A</h2> <p> The CEO of th...
acmicpc tsukuba
No
27,067
s906848745
p01828
u509278866
1528271770
Python
Python3
py
Accepted
50
9024
1,086
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools sys.setrecursionlimit(10**7) inf = 10**20 eps = 1.0 / 10**10 mod = 998244353 def LI(): return [int(x) for x in sys.stdin.readline().split()] def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()] def LF...
p01828
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type='text/javascript' src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script> </script> <h2>M and A</h2> <p> The CEO of th...
acmicpc tsukuba
No
27,068
s032283313
p01828
u853158149
1558690071
Python
Python3
py
Accepted
40
8292
2,609
#!usr/bin/env python3 from collections import defaultdict from collections import deque from heapq import heappush, heappop import sys import math import bisect import random def LI(): return list(map(int, sys.stdin.readline().split())) def I(): return int(sys.stdin.readline()) def LS():return list(map(list, sys.stdin....
p01828
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type='text/javascript' src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script> </script> <h2>M and A</h2> <p> The CEO of th...
acmicpc tsukuba
No
27,069
s800662240
p01830
u260980560
1586433990
Python
Python3
py
Accepted
20
5652
711
import sys readline = sys.stdin.readline write = sys.stdout.write def solve(): N = int(readline()) L = [0]*N; D = [0]*N for i in range(N): l, d = readline().split() L[i] = +(l == 'y') D[i] = int(d) ans = 0 *I, = range(N) I.sort(key = D.__getitem__) U = [0]*N for i...
p01830
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type='text/javascript' src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script> </script> <h2>Delete Files</h2> <p> You are...
3 y 7 y 6 n 5
1
27,070
s847051004
p01831
u078042885
1486708215
Python
Python3
py
Accepted
20
7836
67
n=int(input()) s=input() print(n-min(s.find('>'),n-s.rfind('<')-1))
p01831
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type='text/javascript' src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script> </script> <h2>Line Gimmick</h2> <p> You are ...
7 >>
7
27,071
s243423424
p01831
u858560358
1509013757
Python
Python
py
Accepted
30
6532
222
#!/usr/bin/python import re def main(): n = int(raw_input()) s = raw_input() print n-min(map(lambda x: x.end()-x.start(), [re.search(r'^<*', s), re.search(r'>*$', s)])) if __name__ == '__main__': main()
p01831
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type='text/javascript' src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script> </script> <h2>Line Gimmick</h2> <p> You are ...
7 >>
7
27,072
s926484538
p01831
u858560358
1543832038
Python
Python3
py
Accepted
40
6744
166
import re n = int(input()) s = input() res = 10**10 res = min(res, len(re.search(r'^<*', s).group())) res = min(res, len(re.search(r'>*$', s).group())) print(n-res)
p01831
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type='text/javascript' src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script> </script> <h2>Line Gimmick</h2> <p> You are ...
7 >>
7
27,073
s894127621
p01839
u046108504
1556011712
Python
Python3
py
Accepted
20
5604
424
def solve(): N = int(input()) S = [input() for _ in range(N)] a_count = 1 if S[0] == "A" else -1 # if N == 1 and a_count == -1: # return "NO" for i in range(1, N): if a_count >= 0: a_count += 1 if S[i] == "A" else -1 else: return "NO" if a_count ==...
p01839
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h2>A - 阿吽の呼吸</h2> <h3>Problem Statement</h3> <p...
4 A Un A Un
YES
27,074
s227666453
p01839
u685815919
1481250012
Python
Python
py
Accepted
10
6320
192
n=int(raw_input()) c=0 isValid = True for _ in xrange(n): if raw_input()=="A": c+=1 else: c-=1 if c<0: isValid=False if c!=0: isValid=False if isValid: print "YES" else: print "NO"
p01839
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h2>A - 阿吽の呼吸</h2> <h3>Problem Statement</h3> <p...
4 A Un A Un
YES
27,075
s480961335
p01839
u660912567
1481729903
Python
Python3
py
Accepted
30
7636
163
c = {'A': 0, 'Un': 0} r = 'NO' for _ in range(int(input())): c[input()] += 1 if c['A']<c['Un']: break else: r = 'YES' if c['A']==c['Un'] else 'NO' print(r)
p01839
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h2>A - 阿吽の呼吸</h2> <h3>Problem Statement</h3> <p...
4 A Un A Un
YES
27,076
s404798098
p01839
u301729341
1481796189
Python
Python3
py
Accepted
20
7628
277
n = int(input()) A_cou = 0 Un_cou = 0 ans = "YES" for i in range(n): sen = input() if sen == "A": A_cou += 1 else: Un_cou += 1 if A_cou < Un_cou: ans = "NO" break if A_cou != Un_cou: ans = "NO" print(ans)
p01839
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h2>A - 阿吽の呼吸</h2> <h3>Problem Statement</h3> <p...
4 A Un A Un
YES
27,077
s844484749
p01839
u220324665
1481970316
Python
Python3
py
Accepted
30
7656
106
n=int(input());c=0 for i in range(n): c+=1 if input()=='A'else -1 if c<0:break print("NO"if c else"YES")
p01839
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h2>A - 阿吽の呼吸</h2> <h3>Problem Statement</h3> <p...
4 A Un A Un
YES
27,078
s616506025
p01839
u078042885
1482532273
Python
Python3
py
Accepted
20
7680
252
# -*- coding: utf-8 -*- import sys n=int(input()) a=0 for i in range(n): say=input() if(say=='A'): a+=1 else: a-=1 if(a<0): print("NO") sys.exit() if a: print("NO") else: print("YES")
p01839
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h2>A - 阿吽の呼吸</h2> <h3>Problem Statement</h3> <p...
4 A Un A Un
YES
27,079
s600915132
p01839
u260980560
1483859654
Python
Python
py
Accepted
10
6404
150
n = input() cnt = 0 while n: s = raw_input() cnt += 1-2*(s!='A') if cnt<0:break n-=1 else: if cnt==0:print "YES";exit() print "NO"
p01839
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h2>A - 阿吽の呼吸</h2> <h3>Problem Statement</h3> <p...
4 A Un A Un
YES
27,080
s004615616
p01839
u078042885
1485065087
Python
Python3
py
Accepted
20
7680
104
a=0 for _ in range(int(input())): a+=[-1,1][input()=='A'] if a<0:break print('NO'if a else'YES')
p01839
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h2>A - 阿吽の呼吸</h2> <h3>Problem Statement</h3> <p...
4 A Un A Un
YES
27,081
s839044820
p01839
u078042885
1486117559
Python
Python3
py
Accepted
30
7688
104
a=0 for _ in range(int(input())): a+=[-1,1][input()=='A'] if a<0:break print(['YES','NO'][a!=0])
p01839
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h2>A - 阿吽の呼吸</h2> <h3>Problem Statement</h3> <p...
4 A Un A Un
YES
27,082
s509951131
p01839
u728992264
1490440642
Python
Python3
py
Accepted
30
7676
191
N = int(input()) a = 0 for i in range(N): S = input() if S == 'A': a += 1 else : a -= 1 if a < 0: print('NO') exit() if a == 0: print('YES') else: print('NO')
p01839
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h2>A - 阿吽の呼吸</h2> <h3>Problem Statement</h3> <p...
4 A Un A Un
YES
27,083
s411227929
p01839
u408260374
1492944554
Python
Python3
py
Accepted
20
7668
158
cnt = 0 for _ in range(int(input())): cnt += [-1, 1][input() == "A"] if cnt < 0: print("NO") quit() print("YES" if cnt == 0 else "NO")
p01839
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h2>A - 阿吽の呼吸</h2> <h3>Problem Statement</h3> <p...
4 A Un A Un
YES
27,084
s956958484
p01839
u633333374
1503186732
Python
Python
py
Accepted
10
6452
336
n = int(input()) lst = [] b = 0 for i in range(n): s = str(raw_input()) lst.append(s) if s == "Un": if ("A" in lst) == True: lst.remove("A") lst.remove("Un") else: b = 1 if b != 0: print "NO" else: if len(lst) != 0: print "NO" else: ...
p01839
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h2>A - 阿吽の呼吸</h2> <h3>Problem Statement</h3> <p...
4 A Un A Un
YES
27,085
s282383448
p01839
u741801763
1506370599
Python
Python3
py
Accepted
30
7728
357
if __name__ == "__main__": n = int(input()) data = [] for _ in range(n):data.append(input()) p =[] state = True for i in data: if len(p) ==0 and i =='Un':state = False elif len(p) !=0 and i == 'Un': p.pop() if i =='A':p.append(1) if len(p) !=0:state = False if sta...
p01839
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h2>A - 阿吽の呼吸</h2> <h3>Problem Statement</h3> <p...
4 A Un A Un
YES
27,086
s618324510
p01839
u506554532
1513050687
Python
Python3
py
Accepted
20
5604
218
N = int(input()) src = [input() for i in range(N)] ans = a = 0 for s in src: if s == 'A': a += 1 elif a > 0: a -= 1 else: print('NO') break else: print('YES' if a == 0 else 'NO')
p01839
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h2>A - 阿吽の呼吸</h2> <h3>Problem Statement</h3> <p...
4 A Un A Un
YES
27,087
s927916478
p01839
u285015144
1518704309
Python
Python3
py
Accepted
20
5592
301
N = int(input()) cnt = 0 flag = True for i in range(N): S = input() if(S == 'A'): cnt += 1 elif(S == 'Un'): cnt -= 1 if(cnt < 0): flag = False if(flag == False): print('NO') else: if(cnt == 0): print('YES') else: print('NO')
p01839
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h2>A - 阿吽の呼吸</h2> <h3>Problem Statement</h3> <p...
4 A Un A Un
YES
27,088
s464721629
p01839
u146816547
1524146977
Python
Python
py
Accepted
10
4640
272
N = int(raw_input()) S = [raw_input() for _ in range(N)] cnt = 0 flag = True for i in S: if i == "A": cnt += 1 else: cnt -= 1; if cnt < 0: flag = False break if cnt != 0: flag = False print "YES" if flag else "NO"
p01839
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h2>A - 阿吽の呼吸</h2> <h3>Problem Statement</h3> <p...
4 A Un A Un
YES
27,089
s361430858
p01839
u023471147
1526613899
Python
Python3
py
Accepted
20
5604
284
n = int(input()) talk = [input() for i in range(n)] a = 0 judge = True for s in talk: if s == "A": a += 1 else: if a == 0: judge = False else: a -= 1 if a > 0: judge = False if judge: print("YES") else: print("NO")
p01839
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h2>A - 阿吽の呼吸</h2> <h3>Problem Statement</h3> <p...
4 A Un A Un
YES
27,090
s417179938
p01839
u724548524
1526668513
Python
Python3
py
Accepted
20
5592
193
a = 0 for _ in range(int(input())): if input() == "A":a += 1 else: a -= 1 if a < 0: print("NO") break else: print("YES" if a == 0 else "NO")
p01839
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h2>A - 阿吽の呼吸</h2> <h3>Problem Statement</h3> <p...
4 A Un A Un
YES
27,091
s469681794
p01839
u509278866
1527842219
Python
Python3
py
Accepted
60
9020
903
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools sys.setrecursionlimit(10**7) inf = 10**20 eps = 1.0 / 10**10 mod = 10**9+7 def LI(): return [int(x) for x in sys.stdin.readline().split()] def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()] def LF()...
p01839
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h2>A - 阿吽の呼吸</h2> <h3>Problem Statement</h3> <p...
4 A Un A Un
YES
27,092
s256100823
p01839
u614485948
1528968406
Python
Python3
py
Accepted
20
5592
254
N = int(input()) temp=0 dia_break=0 for _ in range(N): x = input() if x=="A": temp += 1 elif x=='Un': temp -= 1 if temp < 0: dia_break = 1 if dia_break==0 and temp==0: print("YES") else: print("NO")
p01839
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h2>A - 阿吽の呼吸</h2> <h3>Problem Statement</h3> <p...
4 A Un A Un
YES
27,093
s636092641
p01839
u429835330
1528973480
Python
Python3
py
Accepted
20
5596
347
def finish(): print('NO') exit() N = int(input()) cnt = 0 vec = -1 for i in range(N): w = input() if w == 'A': #if vec == -1 and cnt != 0: # finish() cnt += 1 vec = 1 else: if cnt == 0: finish() cnt -= 1 vec = -1 if cnt != 0: ...
p01839
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h2>A - 阿吽の呼吸</h2> <h3>Problem Statement</h3> <p...
4 A Un A Un
YES
27,094
s693602251
p01839
u531592024
1529945032
Python
Python3
py
Accepted
20
5592
204
ge = 0 be = False for i in range(int(input())): if input() == "A": ge += 1 else: ge -= 1 if ge < 0: be = True if be or ge != 0: print("NO") else: print("YES")
p01839
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h2>A - 阿吽の呼吸</h2> <h3>Problem Statement</h3> <p...
4 A Un A Un
YES
27,095
s188246031
p01839
u209989098
1529976022
Python
Python3
py
Accepted
20
5592
226
a = int(input()) aa = 0 un = 0 p = 0 for i in range(a): k = input() if k == 'A': aa += 1 elif k == 'Un': un += 1 if un > aa: p = 1 if aa > un: p = 1 if p == 0: print("YES") else: print("NO")
p01839
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h2>A - 阿吽の呼吸</h2> <h3>Problem Statement</h3> <p...
4 A Un A Un
YES
27,096
s746739114
p01839
u011621222
1530093258
Python
Python3
py
Accepted
20
5592
188
N = int(input()) A = 0 for i in range(N): S = input() if S == "A": A += 1 if i == N-1 or 2*A < i: print("NO") exit() if N%2 == 1 or 2*A != N: print("NO") else: print("YES")
p01839
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h2>A - 阿吽の呼吸</h2> <h3>Problem Statement</h3> <p...
4 A Un A Un
YES
27,097
s044606884
p01839
u352394527
1530095170
Python
Python3
py
Accepted
20
5592
222
n = int(input()) acc = 0 flag = False for _ in range(n): s = input() if s == "A": acc += 1 else: acc -= 1 if acc < 0: flag = True if acc != 0: flag = True if flag: print("NO") else: print("YES")
p01839
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h2>A - 阿吽の呼吸</h2> <h3>Problem Statement</h3> <p...
4 A Un A Un
YES
27,098
s474316836
p01839
u136916346
1530146460
Python
Python3
py
Accepted
20
5604
299
l=[input() for _ in range(int(input()))] s=[] isno=False for i in l: if i=="A": s.append(1) else: try: _=s.pop() except: print("NO") isno=True break if not isno and not s:print("YES") elif not isno and s:print("NO")
p01839
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h2>A - 阿吽の呼吸</h2> <h3>Problem Statement</h3> <p...
4 A Un A Un
YES
27,099
s457915653
p01839
u359849960
1591690932
Python
Python3
py
Accepted
20
5600
594
def AUN(x): a = 0 un = 0 for i in range(len(x)): if x[i] == 'A': a += 1 else: un += 1 if a >= un: return True def p(x): a = 0 un = 0 for i in range(len(x)): if x[i] == 'A': a += 1 else: un += 1 if a =...
p01839
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h2>A - 阿吽の呼吸</h2> <h3>Problem Statement</h3> <p...
4 A Un A Un
YES
27,100
s722249958
p01839
u642694278
1589338489
Python
Python3
py
Accepted
20
5592
181
n = int(input()) d = 0 isOK = True for i in range(n): s = input() if s == "A": d += 1 else: d -= 1 if d < 0: isOK = False if d != 0: isOK = False print("YES" if isOK else "NO")
p01839
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h2>A - 阿吽の呼吸</h2> <h3>Problem Statement</h3> <p...
4 A Un A Un
YES
27,101
s657396217
p01839
u353888999
1586888257
Python
Python3
py
Accepted
20
5604
238
n = int(input()) s = [str(input()) for i in range(n)] cnt = 0 for i in s: if i == "A": cnt += 1 else: cnt -= 1 if cnt < 0: print("NO") exit() if cnt != 0: print("NO") else: print("YES")
p01839
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h2>A - 阿吽の呼吸</h2> <h3>Problem Statement</h3> <p...
4 A Un A Un
YES
27,102
s291832008
p01839
u206124123
1586326429
Python
Python3
py
Accepted
20
5600
895
BEF_STR= "A" AFT_STR = "Un" def get_data(): data = input() return data def make_data_list(num): data_list = [None] * num for i in range(num): data_list[i] = get_data() return data_list #A-Unでワンセットとなるかを確認する関数を作りたい def check_STR1_to_STR2_correspondence(data_list): count = 0 if len(d...
p01839
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h2>A - 阿吽の呼吸</h2> <h3>Problem Statement</h3> <p...
4 A Un A Un
YES
27,103
s238293713
p01839
u153447291
1577964212
Python
Python3
py
Accepted
20
5592
266
a = 0 c = True for i in range(int(input())): b = input() if b == "A": a += 1 else: a -= 1 if a == -1: print("NO") c = False break if c == True: if a == 0: print("YES") else: print("NO")
p01839
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h2>A - 阿吽の呼吸</h2> <h3>Problem Statement</h3> <p...
4 A Un A Un
YES
27,104
s816529502
p01839
u829695570
1577797628
Python
Python3
py
Accepted
20
5592
237
n = int(input()) ans = 'YES' if n%2 == 1: ans = 'NO' cnt = 0 for _ in range(n): s = input() if s == 'A': cnt += 1 elif cnt == 0: ans='NO' else: cnt -= 1 if cnt != 0: ans = 'NO' print(ans)
p01839
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h2>A - 阿吽の呼吸</h2> <h3>Problem Statement</h3> <p...
4 A Un A Un
YES
27,105
s231775917
p01839
u073204138
1574062453
Python
Python3
py
Accepted
30
5592
184
N= int(input()) count = 0 for i in range(N): s = input() if s == "A": count += 1 if s == "Un": count -= 1 if count < 0 : break if count ==0: print("YES") else: print("NO")
p01839
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h2>A - 阿吽の呼吸</h2> <h3>Problem Statement</h3> <p...
4 A Un A Un
YES
27,106
s467171103
p01839
u629590130
1562914991
Python
Python3
py
Accepted
20
5592
200
N = int(input()) a = 0 f = True for _ in range(N): s = input() if s=="A": a += 1 else: if a==0: f = False else: a -= 1 if f and a==0: print("YES") else: print("NO")
p01839
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h2>A - 阿吽の呼吸</h2> <h3>Problem Statement</h3> <p...
4 A Un A Un
YES
27,107
s240933678
p01839
u529214876
1562752941
Python
Python3
py
Accepted
20
5604
272
N = int(input()) S = [input() for _ in range(N)] first = 0 second = 0 ans = "YES" for s in S: if s == "A": first += 1 elif s == "Un": second += 1 if first < second: ans = "NO" break if first != second: ans = "NO" print(ans)
p01839
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h2>A - 阿吽の呼吸</h2> <h3>Problem Statement</h3> <p...
4 A Un A Un
YES
27,108
s662596277
p01839
u731941832
1562482151
Python
Python3
py
Accepted
20
5592
196
a=u=0 for _ in range(int(input())): s=input() if s=='A': a+=1 else: u+=1 if a<u: print('NO') exit() if a==u: print('YES') else: print('NO')
p01839
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h2>A - 阿吽の呼吸</h2> <h3>Problem Statement</h3> <p...
4 A Un A Un
YES
27,109
s363934188
p01839
u537067968
1561620590
Python
Python3
py
Accepted
20
5600
452
n = int(input()) talk = [] ans = "YES" for i in range(n): a = input() if i == 0: talk.append(a) continue if a == "A": if len(talk) != 0 and talk[-1] == "Un": ans = "NO" talk.append(a) else: ...
p01839
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h2>A - 阿吽の呼吸</h2> <h3>Problem Statement</h3> <p...
4 A Un A Un
YES
27,110
s904621431
p01839
u489876484
1561529054
Python
Python3
py
Accepted
20
5600
368
def main(): n = int(input()) count = {"A":0, "Un":0} for _ in range(n): s = input() count[s] += 1 if count["A"] < count["Un"]: return False if count["A"] == count["Un"]: return True else: return False if __name__ == '__main__': if main(): ...
p01839
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h2>A - 阿吽の呼吸</h2> <h3>Problem Statement</h3> <p...
4 A Un A Un
YES
27,111
s523450787
p01839
u037441960
1561033342
Python
Python3
py
Accepted
20
5596
311
N = int(input()) S = list() for i in range(N) : s = input() S.append(s) while True : if(len(S) == 0) : print("YES") break elif("A" in S and "Un" in S) : if(S.index("A") < S.index("Un")) : del S[S.index("A")] del S[S.index("Un")] else : print("NO") break else : print("NO") break
p01839
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h2>A - 阿吽の呼吸</h2> <h3>Problem Statement</h3> <p...
4 A Un A Un
YES
27,112
s563733454
p01839
u598814210
1561003412
Python
Python3
py
Accepted
20
5592
238
N = int(input()) total = 0 for n in range(N): s = input() if s == 'A': total += 1 else: total -= 1 if total < 0: print("NO") exit() if total == 0: print("YES") else: print("NO")
p01839
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h2>A - 阿吽の呼吸</h2> <h3>Problem Statement</h3> <p...
4 A Un A Un
YES
27,113
s937387650
p01839
u328199937
1560584511
Python
Python3
py
Accepted
20
5592
263
N = int(input()) a = 0 un = 0 no = 0 for i in range(N): s = input() if s == "A": a += 1 else: un += 1 if un > a: print("NO") no = 1 break if a != un and not no: print("NO") elif not no: print("YES")
p01839
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h2>A - 阿吽の呼吸</h2> <h3>Problem Statement</h3> <p...
4 A Un A Un
YES
27,114
s063186156
p01839
u340991036
1560326060
Python
Python3
py
Accepted
20
5592
228
n = int(input()) acnt = 0 ok = True for _ in range(n): if input() == 'A': acnt += 1 else: acnt -= 1 if acnt < 0: ok = False if acnt != 0: ok = False print("YES" if ok else "NO")
p01839
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h2>A - 阿吽の呼吸</h2> <h3>Problem Statement</h3> <p...
4 A Un A Un
YES
27,115
s472035409
p01839
u245823788
1560326042
Python
Python3
py
Accepted
20
5604
201
n = int(input()) s = [input() for i in range(n)] cnt = 0 for e in s: if e=="A": cnt += 1 else: cnt -= 1 if cnt<0: print("NO") exit() if cnt==0: print("YES") else: print("NO")
p01839
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h2>A - 阿吽の呼吸</h2> <h3>Problem Statement</h3> <p...
4 A Un A Un
YES
27,116
s930490608
p01839
u853158149
1558683440
Python
Python3
py
Accepted
40
8236
1,341
#!usr/bin/env python3 from collections import defaultdict from collections import deque from heapq import heappush, heappop import sys import math import bisect import random def LI(): return list(map(int, sys.stdin.readline().split())) def I(): return int(sys.stdin.readline()) def LS():return list(map(list, sys.stdin....
p01839
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h2>A - 阿吽の呼吸</h2> <h3>Problem Statement</h3> <p...
4 A Un A Un
YES
27,117
s098007072
p01839
u990228206
1553069926
Python
Python3
py
Accepted
20
5592
226
n=int(input()) A_c=0 Un_c=0 flag=0 for i in range(n): s=input() if s=="A": A_c+=1 elif s=="Un": Un_c+=1 if A_c<Un_c:flag=1 if A_c!=Un_c:flag=1 if flag==0: print("YES") else: print("NO")
p01839
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h2>A - 阿吽の呼吸</h2> <h3>Problem Statement</h3> <p...
4 A Un A Un
YES
27,118
s855343558
p01839
u717526540
1545019101
Python
Python3
py
Accepted
20
5596
353
n = int(input()) remarks = [] for _ in range(n): remarks.append(input()) a = 0 flag = True for remark in remarks: if remark == "A": a += 1 else: if a == 0: flag = False break else: a -= 1 else: if a != 0: flag = False if flag: pr...
p01839
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h2>A - 阿吽の呼吸</h2> <h3>Problem Statement</h3> <p...
4 A Un A Un
YES
27,119
s456610377
p01839
u539753516
1534116377
Python
Python3
py
Accepted
20
5592
158
c=0 for _ in range(int(input())): c+=2*(input()=="A")-1 if c<0: print("NO") break if c==0: print("YES") elif c>0: print("NO")
p01839
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h2>A - 阿吽の呼吸</h2> <h3>Problem Statement</h3> <p...
4 A Un A Un
YES
27,120
s207525061
p01839
u454636644
1528970823
Python
Python3
py
Accepted
20
5596
251
n = int(input()) s_list = [] for ii in range(n): ss = input() s_list.append(ss) c=0 for s in s_list: if(s=="A"): c+=1 else: c-=1 if(c<0): break if(c==0): print("YES") else: print("NO")
p01839
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h2>A - 阿吽の呼吸</h2> <h3>Problem Statement</h3> <p...
4 A Un A Un
YES
27,121
s733499487
p01840
u078042885
1483496416
Python
Python3
py
Accepted
20
7748
208
n,m,t=map(int,input().split()) d=0 a=[int(i) for i in input().split()] b=a[0]-m c=a[0]+m for i in range(1,n): if a[i]>c+m: d+=c-b b=a[i]-m c=a[i]+m if c<t:d+=c-b else:d+=t-b print(t-d)
p01840
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h2>B - 豪邸と宅配便</h2> <h3>Problem Statement</h3> <...
1 1 5 3
3
27,122
s314916309
p01840
u408260374
1492946118
Python
Python3
py
Accepted
30
7732
172
N, M, T = map(int, input().split()) A = [int(x) for x in input().split()] print(A[0] - M + max(T - A[-1] - M, 0) + sum(max(0, A[i+1] - A[i] - 2 * M) for i in range(N - 1)))
p01840
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h2>B - 豪邸と宅配便</h2> <h3>Problem Statement</h3> <...
1 1 5 3
3
27,123
s068077998
p01840
u283315132
1499764381
Python
Python3
py
Accepted
20
7708
265
N, M, T = list(map(int, input().split())) a = list(map(int, input().split())) b = [a[0]] for i in range(1, N): b.append(a[i] - a[i-1]) b.append(T-a[N-1]) ans = 0 ans += b[0] - M for i in range(1, N): ans += max(0, b[i]-2*M) ans += max(0, b[N]-M) print(ans)
p01840
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h2>B - 豪邸と宅配便</h2> <h3>Problem Statement</h3> <...
1 1 5 3
3
27,124
s824751049
p01840
u260980560
1501395602
Python
Python3
py
Accepted
30
7680
225
n, m, t = map(int, input().split()) B = [0]*t *A, = map(int, input().split()) for a in A: B[a-m] += 1 if a+m < t: B[a+m] -= 1 cnt = ans = 0 for b in B: cnt += b if cnt == 0: ans += 1 print(ans)
p01840
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h2>B - 豪邸と宅配便</h2> <h3>Problem Statement</h3> <...
1 1 5 3
3
27,125
s780664543
p01840
u506554532
1513511469
Python
Python3
py
Accepted
20
5596
226
N,M,T = map(int,input().split()) src = list(map(int,input().split())) back_time = ans = 0 for t in src: if t - M > back_time: ans += (t - M - back_time) back_time = t + M ans += max(0, T - back_time) print(ans)
p01840
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h2>B - 豪邸と宅配便</h2> <h3>Problem Statement</h3> <...
1 1 5 3
3
27,126
s646213759
p01840
u285015144
1518704873
Python
Python3
py
Accepted
30
5596
258
N, M, T = map(int, input().split()) a = list(map(int, input().split())) current = 0 ans = 0 ans += max(a[0] - M, 0) current = a[0] for i in range(1, N): ans += max(a[i] - a[i - 1] - 2 * M, 0) current = a[i] ans += max(T - a[N - 1] - M, 0) print(ans)
p01840
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h2>B - 豪邸と宅配便</h2> <h3>Problem Statement</h3> <...
1 1 5 3
3
27,127
s196904030
p01840
u724548524
1526669816
Python
Python3
py
Accepted
20
5596
279
n, m, t = map(int, input().split()) a = list(map(int, input().split())) s = t for i in range(n): if i == 0: s -= m elif a[i] - a[i - 1] >= 2 * m: s -= 2 * m else: s -= a[i] - a[i - 1] if i == n - 1: s -= min(t - a[-1], m) print(s)
p01840
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h2>B - 豪邸と宅配便</h2> <h3>Problem Statement</h3> <...
1 1 5 3
3
27,128
s675525081
p01840
u023471147
1527161226
Python
Python3
py
Accepted
20
5600
215
n, m, t = map(int, input().split()) a = list(map(int, input().split())) a = [-m] + a + [t + m] ans = 0 for i in range(len(a) - 1): if a[i + 1] - a[i] > m * 2: ans += a[i + 1] - a[i] - m * 2 print(ans)
p01840
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h2>B - 豪邸と宅配便</h2> <h3>Problem Statement</h3> <...
1 1 5 3
3
27,129
s138711817
p01840
u509278866
1528106954
Python
Python3
py
Accepted
60
9100
1,197
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools sys.setrecursionlimit(10**7) inf = 10**20 eps = 1.0 / 10**10 mod = 998244353 def LI(): return [int(x) for x in sys.stdin.readline().split()] def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()] def LF...
p01840
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h2>B - 豪邸と宅配便</h2> <h3>Problem Statement</h3> <...
1 1 5 3
3
27,130
s117026621
p01840
u614485948
1528970540
Python
Python3
py
Accepted
20
5604
396
l_raw = input().split() l = [int(n) for n in l_raw] a_raw = input().split() a_ = [int(n) for n in a_raw] study = 0 state = 0 now=0 for a in a_: if state==0: if l[1]<a-now: study+=a-now-l[1] now=a state=1 elif state==1: if 2*l[1]<a-now: study+=a-now-2*l[1...
p01840
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h2>B - 豪邸と宅配便</h2> <h3>Problem Statement</h3> <...
1 1 5 3
3
27,131
s125232191
p01840
u001668877
1528972176
Python
Python3
py
Accepted
20
5716
240
n, m, t = map(int, input().split()) a = list(map(int, input().split())) ts = [0 for i in range(t)] for i in a: ts[max(i - m, 0)] = 2 * m temp = 0 count = 0 for i in range(1, t): ts[i] = max(ts[i - 1] - 1, ts[i]) print(ts.count(0))
p01840
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h2>B - 豪邸と宅配便</h2> <h3>Problem Statement</h3> <...
1 1 5 3
3
27,132
s607391051
p01840
u429835330
1528972786
Python
Python3
py
Accepted
20
5596
281
N, M, T = map(int, input().split()) A = list(map(int, input().split())) prv = 0 cnt = 0 for a in A: if prv == 0: cnt += a - M else: if prv + M < a - M: cnt += (a - M) - (prv + M) prv = a if prv + M < T: cnt += T - (prv + M) print(cnt)
p01840
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h2>B - 豪邸と宅配便</h2> <h3>Problem Statement</h3> <...
1 1 5 3
3
27,133
s694491138
p01840
u314932236
1529807440
Python
Python3
py
Accepted
20
5608
366
import sys sys.setrecursionlimit(10**6) def main(): n, m, t = map(int, input().split()) diff_sum = 0 mini_diff = 0 a = [-1*m] + [i for i in map(int, input().split())] for i in range(n): diff = (2 * m) - (a[i+1] - a[i]) if diff > 0: diff_sum += diff if t-m < a[n]: mini_diff = a[n] + m - t print( t - (2*...
p01840
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h2>B - 豪邸と宅配便</h2> <h3>Problem Statement</h3> <...
1 1 5 3
3
27,134
s937133108
p01840
u531592024
1529944436
Python
Python3
py
Accepted
20
5596
247
(n, m, t) = tuple(map(int, input().split())) arr = list(map(int, input().split())) backed = 0 res = 0 for e in arr: if e - m > backed: res += e - m - backed backed = e + m if arr[-1] + m < t: res += t - arr[-1] - m print(res)
p01840
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h2>B - 豪邸と宅配便</h2> <h3>Problem Statement</h3> <...
1 1 5 3
3
27,135
s272267912
p01840
u136916346
1530533350
Python
Python3
py
Accepted
20
5596
229
N,M,T=map(int,input().split()) l=list(map(int,input().split())) t=0 for (i,j) in enumerate(l): if not i: t+=(l[i]-M) elif (l[i]-l[i-1])>2*M: t+=(l[i]-l[i-1])-2*M if T-l[-1]>M: t+=(T-l[-1])-M print(t)
p01840
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h2>B - 豪邸と宅配便</h2> <h3>Problem Statement</h3> <...
1 1 5 3
3
27,136
s422125928
p01840
u836923362
1596112699
Python
Python3
py
Accepted
20
5736
325
#21:25 n,m,t = map(int,input().split()) arrive_time = list(map(int,input().split())) # list_time = [0]*(t+m+1) for i in arrive_time: # out of bounsの場合どうしよう list_time[i-m] += 1 list_time[i+m] -= 1 for i in range(1,t): list_time[i] += list_time[i-1] print(sum(x==0 for x in list_time[:t]))
p01840
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h2>B - 豪邸と宅配便</h2> <h3>Problem Statement</h3> <...
1 1 5 3
3
27,137
s671470924
p01840
u073204138
1574307400
Python
Python3
py
Accepted
20
5604
217
N, M, T = map(int, input().split()) a = list(int(i) for i in input().split()) count = 0 count += max(a[0] - M,0) for i in range(1,N): count += max(a[i] - a[i-1] -2*M, 0) count += max(T - a[N-1] - M,0) print(count)
p01840
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h2>B - 豪邸と宅配便</h2> <h3>Problem Statement</h3> <...
1 1 5 3
3
27,138
s113353808
p01840
u537067968
1562506247
Python
Python3
py
Accepted
20
5596
258
n,m,t = map(int,input().split()) a = list(map(int,input().split())) ans = a[0] - m for i,aa in enumerate(a): if i != 0 and (aa - a[i-1]) >= 2*m: ans += (aa - a[i-1] - 2*m ) if i == len(a)-1 and (t - aa) >= m: ans += (t - aa - m) continue print(ans)
p01840
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h2>B - 豪邸と宅配便</h2> <h3>Problem Statement</h3> <...
1 1 5 3
3
27,139
s834841464
p01840
u931913851
1562386577
Python
Python3
py
Accepted
20
5600
435
"豪邸と宅配便" N, M, T = map(int, input().split()) # 荷物の個数N, 片道の時間M, 終了時刻T A = list(map(int, input().split())) arraival_span = [A[0]] for i in range(1, N): arraival_span.append(A[i] - A[i-1]) # print(arraival_span) # 最後にT - A[-1]を加える ans = arraival_span[0] - M for i in range(1, len(arraival_span)): ans += max(arr...
p01840
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h2>B - 豪邸と宅配便</h2> <h3>Problem Statement</h3> <...
1 1 5 3
3
27,140
s478207197
p01840
u990228206
1553070437
Python
Python3
py
Accepted
20
5596
196
n,m,t=map(int,input().split()) a=list(map(int,input().split())) a.insert(0,-m) ans=0 for i in range(n): if a[i]+2*m<a[i+1]: ans+=a[i+1]-a[i]-2*m if a[-1]+m<t:ans+=t-a[-1]-m print(ans)
p01840
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h2>B - 豪邸と宅配便</h2> <h3>Problem Statement</h3> <...
1 1 5 3
3
27,141
s198030955
p01840
u454636644
1528971332
Python
Python3
py
Accepted
20
5596
256
n, m, t = map(int, input().split()) a_list = list(map(int, input().split())) ans = 0 ans += max(0, a_list[0] - m) before = a_list[0] for i in range(1, n): ans += max(0, a_list[i]-before-m*2) before = a_list[i] ans += max(0, t-before-m) print(ans)
p01840
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h2>B - 豪邸と宅配便</h2> <h3>Problem Statement</h3> <...
1 1 5 3
3
27,142
s147456860
p01840
u281836941
1514711044
Python
Python3
py
Accepted
20
5812
439
# coding: utf-8 n,m,t=map(int,input().split()) a=list(map(int,input().split())) d=[0] for time in a: f=False if d[-1]<time-m: d.append(max(time-m,0)) else: f=True if f: d[-1]=max(d[-1],time+m) else: d.append(min(time+m,t)) del d[0] data=[False for i in range(t)] i=0 w...
p01840
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h2>B - 豪邸と宅配便</h2> <h3>Problem Statement</h3> <...
1 1 5 3
3
27,143
s246173223
p01841
u509278866
1531293729
Python
Python3
py
Accepted
90
9264
2,009
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools sys.setrecursionlimit(10**7) inf = 10**20 eps = 1.0 / 10**10 mod = 10**9+7 dd = [(-1,0),(0,1),(1,0),(0,-1)] ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)] def LI(): return [int(x) for x in sys.stdin....
p01841
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h2>C - みさわさんの根付き木</h2> <h3>Problem Statement</h3...
((()[8]())[2]())[5](((()[2]())[6](()[3]()))[1]()) (()[4]())[3](((()[2]())[1]())[8](()[3]()))
(()[6]())[8](((()[4]())[7]())[9]())
27,144
s104522308
p01841
u467175809
1531405479
Python
Python
py
Accepted
10
5384
1,085
#!/usr/bin/env python import sys import math import itertools as it from collections import deque sys.setrecursionlimit(10000000) def make_tree(pos, id, S, V, E): if S[pos] == ')': V[id] = -1 return pos + 1, id + 1 par = id id += 1 E[par][0] = id pos, id = make_tree(pos + 1, id, S...
p01841
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h2>C - みさわさんの根付き木</h2> <h3>Problem Statement</h3...
((()[8]())[2]())[5](((()[2]())[6](()[3]()))[1]()) (()[4]())[3](((()[2]())[1]())[8](()[3]()))
(()[6]())[8](((()[4]())[7]())[9]())
27,145
s110664734
p01841
u408260374
1493648582
Python
Python3
py
Accepted
40
7752
894
def parse_node(l, r, S): left, right = 0, 0 cnt = 0 for i in range(l, r + 1): if S[i] == '(': cnt += 1 elif S[i] == ')': cnt -= 1 elif cnt == 0 and S[i] == "[": left = i elif cnt == 0 and S[i] == "]": right = i return left, ...
p01841
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h2>C - みさわさんの根付き木</h2> <h3>Problem Statement</h3...
((()[8]())[2]())[5](((()[2]())[6](()[3]()))[1]()) (()[4]())[3](((()[2]())[1]())[8](()[3]()))
(()[6]())[8](((()[4]())[7]())[9]())
27,146
s112573259
p01841
u260980560
1501397346
Python
Python3
py
Accepted
30
7804
602
def convert(S): cur = 0 def parse(): nonlocal cur if S[cur] == ')': return () cur += 1 # '(' left = parse() cur += 2 # ')[' num = 0 while S[cur] != ']': num = 10*num + int(S[cur]) cur += 1 cur += 2 # '](' ...
p01841
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <h2>C - みさわさんの根付き木</h2> <h3>Problem Statement</h3...
((()[8]())[2]())[5](((()[2]())[6](()[3]()))[1]()) (()[4]())[3](((()[2]())[1]())[8](()[3]()))
(()[6]())[8](((()[4]())[7]())[9]())
27,147