🚀

2022/04/02に公開

A - Four Digits

``````import sys
import heapq, math, itertools
from collections import defaultdict, deque
from bisect import bisect_left, bisect_right, insort_left, insort_right
mod = 10**9+7
inf = float('inf')
#sys.setrecursionlimit(10**7)

def main():
print(input().zfill(4))

if __name__ == '__main__':
main()
``````

``````import sys
import heapq, math, itertools
from collections import defaultdict, deque
from bisect import bisect_left, bisect_right, insort_left, insort_right
mod = 10**9+7
inf = float('inf')
#sys.setrecursionlimit(10**7)

def main():
n,p = map(int, inputs().split())
a = list(map(int, inputs().split()))
ans = 0
for i in range(n):
if a[i]<p:
ans += 1
print(ans)

if __name__ == '__main__':
main()
``````

C - Swiss-System Tournament

``````import sys
import heapq, math, itertools
from collections import defaultdict, deque
from bisect import bisect_left, bisect_right, insort_left, insort_right
mod = 10**9+7
inf = float('inf')
#sys.setrecursionlimit(10**7)

def is_won(u,v):
if (u=='G' and v=='C') or (u=='C' and v=='P') or (u=='P' and v=='G'):
return True
else:
return False

def main():
n,m = map(int, inputs().split())
a = [input() for _ in range(2*n)]
result = [(i,0) for i in range(2*n)]
for i in range(m):
nx = []
for j in range(n):
x1,c1 = result[2*j]
x2,c2 = result[2*j+1]
hand1 = a[x1][i]
hand2 = a[x2][i]
if is_won(hand1, hand2):
c1 += 1
if is_won(hand2, hand1):
c2 += 1
nx.append((-x1,c1))
nx.append((-x2,c2))
nx = sorted(nx, key=lambda x:[x[1], x[0]], reverse=True)
nx = [(-i,j) for i,j in nx]
result = nx
for i in range(2*n):
print(result[i][0]+1)

if __name__ == '__main__':
main()
``````

D - Between Two Arrays

``````import sys
import heapq, math, itertools
from collections import defaultdict, deque
from bisect import bisect_left, bisect_right, insort_left, insort_right
mod = 998244353
inf = float('inf')
#sys.setrecursionlimit(10**7)

def main():
n = int(input())
a = list(map(int, inputs().split()))
b = list(map(int, inputs().split()))
dp = [[0]*3001 for _ in range(n+1)]
dp[0][0] = 1
for i in range(n):
s = sum(dp[i][:a[i]])%mod
for c in range(a[i], b[i]+1):
s += dp[i][c]
s %= mod
dp[i+1][c] = s
print(sum(dp[-1])%mod)

if __name__ == '__main__':
main()
``````