This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import Counter | |
N = int(input()) | |
a = list(map(int, input().split())) | |
ans = 0 | |
for k, v in Counter(a).items(): | |
if k < v: | |
ans += (v-k) | |
if k > v: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
s = input() | |
s_asc = ''.join(sorted(s)) | |
t = input() | |
t_dsc = ''.join(sorted(t, reverse = True)) | |
if s_asc < t_dsc: | |
print('Yes') | |
else: | |
print('No') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
s = input() | |
print(s.rfind('Z') - s.find('A') + 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
INF = float('inf') | |
def solve(): | |
N, Ma, Mb = map(int, input().split()) | |
l = [] | |
for _ in range(N): | |
a, b, c = map(int, input().split()) | |
l.append((a, b, c)) | |
dp = [[[INF] * 401 for _ in range(401)] for _ in range(N + 1)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
N, M = map(int, input().split()) | |
g = [[] for i in range(N)] #隣接リスト | |
for i in range(M): | |
a, b = map(int, input().split()) | |
g[a-1].append(b-1) | |
g[b-1].append(a-1) | |
memo = {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
N, M = map(int, input().split()) | |
adj_matrix = [[0]* N for _ in range(N)] | |
for i in range(M): | |
a, b = map(int, input().split()) | |
adj_matrix[a-1][b-1] = 1 | |
adj_matrix[b-1][a-1] = 1 | |
def dfs(v, used): | |
if not False in used: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import itertools | |
N, M = map(int, input().split()) | |
adj_matrix = [[0]* N for _ in range(N)] | |
for i in range(M): #隣接行列 | |
a, b = map(int, input().split()) | |
adj_matrix[a-1][b-1] = 1 | |
adj_matrix[b-1][a-1] = 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
N, M = map(int, input().split()) | |
if M >= 2 * N: | |
M_left = M - 2 * N | |
print(N + M_left // 4) | |
else: | |
print(M // 2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
N = int(input()) | |
C = 10**9+7 | |
ans = 1 | |
for i in range(1, N + 1): | |
ans *= i | |
ans %= C | |
print(ans) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
N = int(input()) | |
C = 10**9 + 7 | |
print(math.factorial(N) % C) |
NewerOlder