input stringlengths 20 127k | target stringlengths 20 119k | problem_id stringlengths 6 6 |
|---|---|---|
A,B,C,X,Y=list(map(int,input().split()))
ans=10**12
for i in range(10**5+1):
temp=i*2*C+max(0,X-i)*A+max(0,Y-i)*B
ans=min(ans,temp)
print(ans)
| A,B,C,X,Y=list(map(int,input().split()))
ans=0
if 2*C<A+B:
Z=min(X,Y)
X-=Z
Y-=Z
ans+=2*C*Z
A=min(A,2*C)
B=min(B,2*C)
ans+=A*X
ans+=B*Y
print(ans)
| p03373 |
import math
import queue
from collections import defaultdict
def readInt():
return int(eval(input()))
def readInts():
return list(map(int, input().split()))
def readChar():
return eval(input())
def readChars():
return input().split()
def factorization(n):
res = []
if n%2==0:
res.append(2)
for... | import math
import queue
from collections import defaultdict
def readInt():
return int(eval(input()))
def readInts():
return list(map(int, input().split()))
def readChar():
return eval(input())
def readChars():
return input().split()
def factorization(n):
res = []
if n%2==0:
res.append(2)
for... | p03373 |
A, B, C, X, Y = tuple(map(int, input().split()))
# 大きな値で初期化
TOTAL_MIN = A * X + B * Y + C * (X+Y) * 2
if 2 * C < A:
i_max = 0
else:
i_max = X
if 2 * C < B:
j_max = 0
else:
j_max = Y
for i in range(i_max + 1):
for j in range(j_max + 1):
k = max(X - i, Y - j) * 2
to... | A, B, C, X, Y = tuple(map(int, input().split()))
# 大きな値で初期化
TOTAL_MIN = A * X + B * Y + C * (X+Y) * 2
for a in range(X + 1):
c = (X - a) * 2
if c // 2 < Y:
if B < 2 * C:
b = Y - c // 2
else:
b = 0
c = max(c, Y * 2)
else:
b = 0
... | p03373 |
import sys
def input():
return sys.stdin.readline()[:-1]
def ii(t: type = int):
return t(eval(input()))
def il(t: type = int):
return list(map(t, input().split()))
def imi(N: int, t: type = int):
return [ii(t) for _ in range(N)]
def iml(N: int, t: type = int):
return [i... | import sys
def input():
return sys.stdin.readline()[:-1]
def ii(t: type = int):
return t(eval(input()))
def il(t: type = int):
return list(map(t, input().split()))
def imi(N: int, t: type = int):
return [ii(t) for _ in range(N)]
def iml(N: int, t: type = int):
return [i... | p03373 |
a, b, c, x, y = list(map(int, input().split(" ")))
res = 10**10
for i in range(0, max(x, y)*2+2, 2):
a_piza = max(0, x - (i // 2))
b_piza = max(0, y - (i // 2))
res = min(res, a_piza*a + b_piza*b + i*c)
print(res)
| a, b, c, x, y = list(map(int, input().split(" ")))
print((min([max(0, x-(i//2))*a + max(0, y-(i//2))*b + i*c for i in range(0, max(x, y)*2+2, 2)])))
| p03373 |
x,y=list(map(int,input().split()));print((' YNeos'[len(set([2 if i in [2] else 1 if i in [4,6,9,11] else 0 for i in [x,y]]))::2])) | print((' YNeos'[len(set([2 if i in [2] else 1 if i in [4,6,9,11] else 0 for i in list(map(int,input().split()))]))::2])) | p03711 |
a,b,c=[1,3,5,7,8,10,12],[4,6,9,11],[2]
print(('YNeos'[len(set([0 if i in a else [1,2][i in b] for i in list(map(int,input().split()))]))!=1::2])) | print(('YNeos'[len(set([0 if i==2 else [1,2][i in [4,6,9,11]] for i in list(map(int,input().split()))]))!=1::2])) | p03711 |
# ABC062A - Grouping
x, y = list(map(int, input().rstrip().split()))
a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
if x == y:
print("Yes")
elif x in a and y in a:
print("Yes")
elif x in b and y in b:
print("Yes")
else:
print("No") | # ABC062A - Grouping
x, y = list(map(int, input().rstrip().split()))
lst = [[1, 3, 5, 7, 8, 10, 12], [4, 6, 9, 11]]
for i in lst:
if x in i and y in i:
print("Yes")
exit()
print("No") | p03711 |
x , y = list(map(int,input().split()))
list1 = [1,3,5,7,8,10,12]
list2 = [4,6,9,11]
list3 = [2]
if x in list1:
print(('Yes' if y in list1 else 'No'))
if x in list2:
print(('Yes' if y in list2 else 'No'))
if x in list3:
print(('Yes' if y in list3 else 'No')) | x , y = list(map(int,input().split()))
list1 = [1,3,5,7,8,10,12]
list2 = [4,6,9,11]
list3 = [2]
if x in list1 and y in list1:
print('Yes')
elif x in list2 and y in list2:
print('Yes')
elif x in list3 and y in list3:
print('Yes')
else:
print('No')
| p03711 |
x,y = list(map(int, input().split()))
a = [1,3,5,7,8,10,12]
b = [4,6,9,11]
c = [2]
if x in a and y in a:
print('Yes')
elif x in b and y in b:
print('Yes')
else:
print('No') | x,y = list(map(int, input().split()))
a = [1,3,5,7,8,10,12]
b = [4,6,9,11]
c =[2]
if x in a and y in a:
print('Yes')
elif x in b and y in b:
print('Yes')
elif x==y==2:
print('Yes')
else:
print('No') | p03711 |
x,y = list(map(int,input().split()))
li = [[1,3,5,7,8,10,12],[4,6,9,11],[2]]
for i in li:
if x in i and y in i:
print("Yes")
exit()
print("No") | import sys
x,y = list(map(int,input().split()))
li = [[1,3,5,7,8,10,12],[4,6,9,11],[2]]
for i in li:
if x in i and y in i:
print("Yes")
sys.exit()
print("No") | p03711 |
x,y = list(map(int, input().split()))
A=[1,3,5,7,8,10,12]
B=[4,6,9,11]
C=[2]
if (x in A and y in A) or (x in B and y in B) or (x in C and y in C):
print('Yes')
else:
print('No') | x,y = list(map(int, input().split()))
A = {1, 3, 5, 7, 8, 10, 12}
B = {4, 6, 9, 11}
print(("Yes" if {x, y} <= A or {x, y} <= B else "No")) | p03711 |
x,y=input().split()
a={"1","3","5","7","8","10","12"}
b={"4","6","9","11"}
print(("Yes" if {x,y}<=a or {x,y}<=b else "No")) | S="XACABABAABABA"
x,y=list(map(int,input().split()))
print(("Yes" if S[x]==S[y] else "No")) | p03711 |
s = set(map(int, input().split()))
b, c = {4, 6, 9, 11}, {2}
a = {i for i in range(1, 13)}-b-c
print(('Yes' if any(x & s == s for x in (a, b, c)) else 'No'))
| a = [{1, 3, 5, 7, 8, 10, 12}, {4, 6, 9, 11}, {2}]
s = set(map(int, input().split()))
print(('Yes' if any(s <= x for x in a) else 'No'))
| p03711 |
x, y = list(map(int, input().split(" ")))
group_list = [[1, 3, 5, 7, 8, 10, 12], [4, 6, 9, 11], [2]]
finished = False
for gl in group_list:
if (x in gl) and (y in gl):
print("Yes")
finished = True
if finished != True:
print("No") | x, y = list(map(int, input().split(" ")))
group_list = [[1, 3, 5, 7, 8, 10, 12], [4, 6, 9, 11], [2]]
for i in range(3):
if x in group_list[i]:
if y in group_list[i]:
print("Yes")
else:
print("No") | p03711 |
#coding: utf-8
group={'a':[1,3,5,7,8,10,12],'b':[4,6,9,11],'c':[2]}
input_lines=input()
input_numbers=input_lines.split()
n=list(map(int,input_numbers))#n[0]とn[1]に数字
first_group = False
second_group = False
for i in group:
for j in range(0,len(group[i])):
if group[i][j] == n[0]:
... | group =[0,1,3,1,2,1,2,1,1,2,1,2,1]
input_lines=input()
input_numbers=input_lines.split()
n=list(map(int,input_numbers))
if group[n[0]] == group[n[1]]:
print("Yes")
else:
print("No") | p03711 |
a,b=input().split()
lis=(("1","3","5","7","8","10","12"),("4","6","9","11"),("2"))
for gn, row in enumerate(lis):
try:
A=(gn, row.index(a))
break
except ValueError:
pass
for gn, row in enumerate(lis):
try:
B=(gn, row.index(b))
break
except ValueError:
... | x,y = list(map(int,input().split(" ")))
a=(1,3,5,7,8,10,12)
b=(4,6,9,11)
if (x in a and y in a) or (x in b and y in b):
print("Yes")
else:
print("No") | p03711 |
x, y = list(map(int, input().split()))
G = [[1, 3, 5, 7, 8, 10, 12], [4, 6, 9, 11], [2]]
print(('Yes' if any(x in g and y in g for g in G) else 'No')) | G = [[1, 3, 5, 7, 8, 10, 12], [4, 6, 9, 11], [2]]
x, y = list(map(int, input().split()))
print(('Yes' if any(x in g and y in g for g in G) else 'No')) | p03711 |
x, y = list(map(int, input().split()))
A = [[1, 3, 5, 7, 8, 10, 12], [4, 6, 9, 11], [2]]
ans = 'No'
for a in A:
if x in a and y in a:
ans = 'Yes'
break
print(ans) | x, y = list(map(int, input().split()))
A = [[1, 3, 5, 7, 8, 10, 12], [4, 6, 9, 11], [2]]
ans = 'No'
for a in A:
if x in a and y in a:
ans = 'Yes'
print(ans) | p03711 |
a,b=list(map(int,input().split()))
k=list(map(int,input().split()))
sa=0
ans=1
ma=max(k)
for i in range(a-1):
if k[i]==ma:
ma=max(k[i+1:a])
tmp=ma-k[i]
if tmp>sa:
sa=tmp
ans=1
elif tmp==sa:
ans+=1
print(ans) | a,b=list(map(int,input().split()))
k=list(map(int,input().split()))
sa=0
ans=1
n=k[a-1]
for i in range(a-2,-1,-1):
if k[i]>n:
n=k[i]
tmp=n-k[i]
if tmp>sa:
sa=tmp
ans=1
elif tmp==sa:
ans+=1
print(ans) | p03946 |
N, T = list(map(int, input().split()))
num_list = input().split()
num_list = [int(x) for x in num_list]
dif = 0
count = 0
for index, i in enumerate(num_list):
for j in num_list[index:]:
# print(j)
if j > i and (j - i) >= dif:
dif = j - i
for index, i in enumerate(num_list)... | N, T = list(map(int, input().split()))
num_list = input().split()
num_list = [int(x) for x in num_list]
count = 0
profit = 0
min_val = num_list[0]
for num in num_list:
if num < min_val:
min_val = num
elif num - min_val == profit:
count += 1
elif num - min_val > profit:
... | p03946 |
N, T = [int(v) for v in input().split()]
a = [int(v) for v in input().split()]
max_profit = 0
ans = 1
left = 0
right = 1
while right < N:
if a[left] < a[right]:
profit = a[right] - a[left]
if profit == max_profit:
ans += 1
else:
max_profit = max(max_pr... | N, T = [int(v) for v in input().split()]
a = [int(v) for v in input().split()]
max_profit = 0
ans = 1
left = 0
right = 1
min_a = a[0]
for i in range(1, N):
if min_a < a[i]:
profit = a[i] - min_a
if profit == max_profit:
ans += 1
else:
max_profit = max... | p03946 |
from bisect import bisect_left
from collections import defaultdict
N, T, *A = list(map(int, open(0).read().split()))
inf = 10 ** 9 + 7
dp = [inf] * (N + 1)
ctr = defaultdict(int)
for i in range(N):
idx = bisect_left(dp, A[i])
dp[idx] = A[i]
if idx != 0:
ctr[A[i] - dp[0]] += 1
print(... | from collections import defaultdict
N, T, *A = list(map(int, open(0).read().split()))
ctr = defaultdict(int)
m = 10 ** 9 + 7
for i in range(N):
m = min(m, A[i])
ctr[A[i] - m] += 1
print((ctr[max(ctr)]))
| p03946 |
N,T = list(map(int,input().split()))
A = list(map(int,input().split()))
dif = []
max_A = 0
for i in range(N):
max_A = max(max_A,A[-1-i])
dif.append(max_A-A[-1-i])
ans = 0
dif.sort(reverse=True)
for i in range(N-1):
if dif[i]!=dif[i+1]:
print((i+1))
break | N, T = list(map(int, input().split()))
A = list(map(int, input().split()))
lo = 10**18
hi = 0
d = 0
res = 0
for i in range(N):
if lo > A[i]:
lo = A[i]
hi = 0
if hi < A[i]:
hi = A[i]
if d == hi - lo:
res += 1
elif d < hi - lo:
d... | p03946 |
N, T = list(map(int, input().split()))
A = [int(x) for x in input().split()]
buy = A[0]
max_profit = 0
ans = 1
for i in range(1,N):
if A[i] > buy:
if A[i] - buy > max_profit:
max_profit = A[i] - buy
ans = 1
elif A[i] - buy == max_profit:
ans += 1
e... | N, T = list(map(int, input().split()))
A = [int(x) for x in input().split()]
cost, buy, mprofit = 1, 10e9, 0
for a in A:
if a < buy:
buy = a
else:
profit = a - buy
if profit == mprofit:
cost += 1
if profit > mprofit:
mprofit = profit
... | p03946 |
N, T = list(map(int, input().split()))
A = list(map(int, input().split()))
B = [A[i:] for i in range(1, N)]
ans = 0
maxv = 0
for i in range(N-1):
z = max(B[i]) - A[i]
if maxv > z:
continue
elif maxv < z:
maxv = z
ans = 1
else:
ans += 1
print(ans)
| N, T = list(map(int, input().split()))
A = list(map(int, input().split()))
B = [max(A[i:]) for i in range(1, N)]
ans = 0
maxv = 0
for i in range(N-1):
z = B[i] - A[i]
if maxv > z:
continue
elif maxv < z:
maxv = z
ans = 1
else:
ans += 1
print(ans) | p03946 |
N, T = list(map(int, input().split()))
A = list(map(int, input().split()))
B = [max(A[i:]) for i in range(1, N)]
ans = 0
maxv = 0
for i in range(N-1):
z = B[i] - A[i]
if maxv > z:
continue
elif maxv < z:
maxv = z
ans = 1
else:
ans += 1
print(ans) | N, T = list(map(int, input().split()))
A = list(map(int, input().split()))
B = A[::-1]
C = []
maxv = 0
for i in range(N):
if maxv > B[i]:
C.append(maxv)
else:
maxv = B[i]
C.append(maxv)
C = C[::-1]
ans = 0
maxv = 0
for i in range(N-1):
z = C[i] - A[i]
if max... | p03946 |
N, T = list(map(int, input().split()))
A = list(map(int, input().split()))
B = A[::-1]
C = []
maxv = 0
for i in range(N):
if maxv > B[i]:
C.append(maxv)
else:
maxv = B[i]
C.append(maxv)
C = C[::-1]
ans = 0
maxv = 0
for i in range(N-1):
z = C[i] - A[i]
if max... | N, T = list(map(int, input().split()))
A = list(map(int, input().split()))
maxp = 0
minv = float('inf')
ans = 0
for a in A:
p = a - minv
if p > maxp:
maxp = p
ans = 1
elif p == maxp:
ans += 1
minv = min(minv, a)
print(ans) | p03946 |
# ABC047D - 高橋君と見えざる手 / An Invisible Hand (ARC063D)
def main():
N, T = tuple(map(int, input().split()))
A = tuple(map(int, input().split()))
cur, cand = A[0], []
for i in A:
if i < cur:
cur = i
else:
cand += [i - cur]
x = max(cand)
ans = sum(i =... | # ABC047D - 高橋君と見えざる手 / An Invisible Hand (ARC063D)
def main():
N, T, *A = list(map(int, open(0).read().split()))
cur, cand = A[0], []
for i in A:
if i < cur:
cur = i
else:
cand += [i - cur]
x = max(cand)
ans = len([1 for i in cand if i == x])
p... | p03946 |
n,t = list(map(int,input().split()))
a = list(map(int,input().split()))
ans = [0]*n
for i in range(n):
flag = min(a[:i+1])
ans[i] = a[i]-flag
print((ans.count(max(ans)))) | n,t = list(map(int,input().split()))
a = list(map(int,input().split()))
ans = [0]*n
flag = float("inf")
for i in range(n):
flag = min(flag,a[i])
ans[i] = a[i]-flag
print((ans.count(max(ans)))) | p03946 |
def main():
n, t, *a = list(map(int, open(0).read().split()))
a += [-float("Inf")]
b = [max(a[i + 1:]) for i in range(n)]
c = []
for i in range(n):
x = a[i]
y = b[i]
c.append(y - x)
d = c.count(max(c))
print(d)
if __name__ == '__main__':
main()
| def main():
n, t, *a = list(map(int, open(0).read().split()))
b = 0
c = float("Inf")
d = 0
for i in range(n):
x = a[i]
if x - c > b:
b = x - c
d = 1
elif x - c == b:
d += 1
c = min(c, x)
print(d)
if __name__ ... | p03946 |
n, t = list(map(int, input().split()))
a = list(map(int, input().split()))
saeki = []
maxsaeki = 0
ans = 0
maxringo = max(a)
for i in range(len(a)-1):
if a[i] == maxringo:
maxringo = max(a[i+1:])
s = maxringo - a[i]
if s == maxsaeki:
ans += 1
if s > maxsaeki:
ans... | n, t = list(map(int, input().split()))
a = list(map(int, input().split()))
ma = a[-1]
m = 1
maxsaeki = 0
ans = 0
for i in range(n-2,-1,-1):
if a[i] > ma:
ma = a[i]
m = 1
elif a[i] < ma:
if (ma - a[i]) > maxsaeki:
maxsaeki = ma-a[i]
ans = 1
... | p03946 |
n,t=list(map(int,input().split()))
a=list(map(int,input().split()))
saisyo=min(a)
saidai=0
count=0
for i in range(n-1):
x=a.pop()
if x==saisyo:
saisyo=min(a)
elif x-saisyo>=saidai:
mouke=x-saisyo
if mouke>saidai:
saidai=mouke
count=1
el... | n,t=list(map(int,input().split()))
a=list(map(int,input().split()))
saisyo=a[0]
saidai=0
count=0
for i in range(n):
if a[i]<saisyo:saisyo=a[i]
else:
if a[i]-saisyo>saidai:
saidai=a[i]-saisyo
count=1
elif a[i]-saisyo==saidai:
count+=1
print(count) | p03946 |
input('').split()
A = [int(x) for x in input('').split()]
max = 0
msp = A[0]
for i in range(0,len(A)-1):
if msp <= A[i]:
continue
else:
msp = A[i]
for j in range(i+1,len(A)):
pf_t = A[j] - A[i]
if pf_t > max:
max = pf_t
spot = [(i,j)]
elif pf_t =... | input('').split()
A = [int(x) for x in input('').split()]
max = 0
count = 0
pl = 0
msp = A[0]
for i in range(1,len(A)):
pl_t = pl + A[i] - A[i-1]
if pl_t <= 0:
pl = 0
else:
pl = pl_t
if max < pl_t:
max = pl_t
count = 1
elif max == pl_t:
count += 1
print(count) | p03946 |
n, t = list(map(int, input().split()))
a = list(map(int, input().split()))
max_benefit = 0
ans = 0
for i in range(n - 1):
benefit = (max(a[i + 1:]) - a[i])
if benefit == max_benefit:
ans += 1
elif benefit > max_benefit:
ans = 1
max_benefit = benefit
print(ans) | n, t = list(map(int, input().split()))
a = list(map(int, input().split()))
max_benefit = 0
a_min = a[0]
ans = 0
for i in range(1, n):
if a[i] < a_min:
a_min = a[i]
benefit = (a[i] - a_min)
if benefit == max_benefit:
ans += 1
elif benefit > max_benefit:
ans = 1
... | p03946 |
import heapq
n,t = list(map(int,input().split()))
ai = [int(i) for i in input().split()]
rev_ai = [ai[n-1]*(-1)]
ans = [0,0]
heapq.heapify(rev_ai)
#print(rev_ai)
for i in range(1,n):
#print(ai[n-1-i])
dif = rev_ai[0]*(-1) - ai[n-1-i]
if dif > ans[0]:
ans = [dif,1]
elif dif ==... | #import heapq
n,t = list(map(int,input().split()))
ai = [int(i) for i in input().split()]
#rev_ai = [ai[n-1]*(-1)]
ans = [0,0]
max_ai = ai[n-1]
#heapq.heapify(rev_ai)
#print(rev_ai)
for i in range(1,n):
#print(ai[n-1-i])
dif = max_ai - ai[n-1-i]
if dif > ans[0]:
ans = [dif,1]
... | p03946 |
n, t = list(map(int, input().split()))
a = list(map(int, input().split()))
remain_max = [a[-1]]*n
for i in range(1, n):
remain_max[-(i+1)] = max(a[-i], remain_max[-i])
diffs1 = [0]*n
for i in range(n):
diffs1[i] = remain_max[i] - a[i]
max_diff1 = 0
ans1 = 0
for i in range(n):
if diffs1[i] >... | n, t = list(map(int, input().split()))
a = list(map(int, input().split()))
remain_max = [a[-1]]*n
for i in range(1, n):
remain_max[-(i+1)] = max(a[-i], remain_max[-i])
diffs = [0]*n
for i in range(n):
diffs[i] = remain_max[i] - a[i]
max_diff = 0
ans = 0
for i in range(n):
if diffs[i] > max_... | p03946 |
from itertools import combinations
n, t = list(map(int, input().split()))
a = list(map(int, input().split()))
diff = sorted([t[1]-t[0] for t in combinations(a, 2)], reverse=True)
print((diff.count(diff[0]))) | n, t = list(map(int, input().split()))
a = list(map(int, input().split()))
mn = a[0]
l = []
for x in a:
l.append(x-mn)
mn = min(mn, x)
l.sort()
print((l.count(l[-1])))
| p03946 |
n, t = list(map(int, input().split()))
a = list(map(int, input().split()))
mn = a[0]
d = {}
for x in a:
d[x-mn] = d.get(x-mn, 0) + 1
mn = min(mn, x)
print((max(list(d.items()), key=lambda x:x[0])[1]))
| n, t = list(map(int, input().split()))
a = list(map(int, input().split()))
mn = a[0]
d = {}
for x in a:
d[x-mn] = d.get(x-mn, 0) + 1
mn = min(mn, x)
print((d[max(d.keys())]))
| p03946 |
N, T = list(map(int, input().split()))
A = list(map(int, input().split()))
benefit = -1
cost = 1
for i in range(N - 1):
for j in range(i + 1, N):
if benefit == A[j] - A[i]:
cost += 1
if benefit < A[j] - A[i]:
cost = 1
benefit = A[j] - A[i]
print(c... | N, T = list(map(int, input().split()))
A = list(map(int, input().split()))
minA = A[0]
benefit = 0
maxBenefit = 0
cost = 0
for i in range(N):
if A[i] < minA:
minA = A[i]
else:
benefit = A[i] - minA
if benefit > maxBenefit:
maxBenefit = benefit
cos... | p03946 |
import sys
from heapq import heappush, heappop
from collections import Counter
n, t, *a = list(map(int, sys.stdin.read().split()))
def main():
cand = []
hq = [a[0]]
for x in a[1:]:
y = heappop(hq)
cand.append(x - y)
heappush(hq, x)
heappush(hq, y)
c = Counter(cand)
ans = c[max... | import sys
from collections import Counter
n, t, *a = list(map(int, sys.stdin.read().split()))
def main():
cand = []
mi = a[0]
for x in a[1:]:
cand.append(x - mi)
mi = min(mi, x)
c = Counter(cand)
ans = c[max(c.keys())]
print(ans)
if __name__ == '__main__':
main() | p03946 |
def readints(): return list(map(int,input().split()))
N, T = readints()
a = list(readints())
mdiff = 0
mi = 1145141919
for i in range(N):
mi = min(mi, a[i])
mdiff = max(mdiff, a[i] - mi)
mi = 1145141919
ans = 0
for i in range(N):
mi = min(mi, a[i])
ans += (a[i] - mi == mdiff)
print(... | def readints(): return list(map(int,input().split()))
N, T = readints()
a = list(readints())
mdiff = 0
mi = 1145141919
for x in a:
mi = min(mi, x)
mdiff = max(mdiff, x - mi)
mi = 1145141919
ans = 0
for x in a:
mi = min(mi, x)
ans += (x - mi == mdiff)
print(ans) | p03946 |
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digi... | import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digi... | p03946 |
N,T = list(map(int,input().split()))
A = list(map(int,input().split()))
minA = A[0]
profit = 0
cnt = 0
for i in range(1,N):
# A[i] で min(A[0..i-1])を売る場合の利益
p = A[i]-minA
if p==profit:
cnt += 1
elif p>profit:
profit = p
cnt = 1
# min(A[0..i]) の更新
minA = mi... | # python3 (3.4.3)
import sys
input = sys.stdin.readline
# main
N,T = list(map(int,input().split()))
A = list(map(int,input().split()))
lowest = 10**9+1
profit = 0
ans = 0
for a in A:
lowest = min(lowest, a)
if a - lowest == profit:
ans += 1
elif a - lowest > profit:
profi... | p03946 |
n, t = list(map(int, input().split()))
a = list([int(x) for x in input().split()])
#a = list(map(lambda x: int(x), in1.split()))
w_a = []
str_a = 0
for idx1 in range(len(a) - 1):
w_a.append(a[idx1])
if a[idx1 + 1] - min(w_a) > str_a:
RC = 1
str_a = a[idx1 + 1] - min(w_a)
elif a[i... | n, t = list(map(int, input().split()))
a = list([int(x) for x in input().split()])
#a = list(map(lambda x: int(x), in1.split()))
b = []
strlow = a[0]
for idx1 in range(1, len(a)):
b.append(a[idx1] - strlow)
if a[idx1] < strlow:
strlow = a[idx1]
print((b.count(max(b))))
| p03946 |
from collections import defaultdict
N, T = list(map(int, input().split()))
*a, = list(map(int, input().split()))
t = defaultdict(int)
m = a[0]
p = 0
ans = 0
for i in range(1, N):
c = a[i] - m
if t[m] < c:
t[m] = c
if a[i] < m:
m = a[i]
if c > p:
p = c
ans... | N, T = list(map(int, input().split()))
*a, = list(map(int, input().split()))
m = a[0]
p = 0
ans = 0
for i in range(1, N):
c = a[i] - m
if a[i] < m:
m = a[i]
if c > p:
p = c
ans = 1
elif c == p:
ans += 1
print(ans)
| p03946 |
N, T = list(map(int, input().split()))
A = list(map(int, input().split()))
mx = [0] * (N + 1)
for i, a in enumerate(A[::-1], start=1):
mx[-i] = max(mx[-i + 1], a)
mxD = 0
ans = 0
for i, a in enumerate(A):
d = mx[i + 1] - a
if mxD < d:
mxD = d
ans = 0
if mxD == d:
... | N, _ = list(map(int, input().split()))
A = list(map(int, input().split()))
mi = 10**18
mx = -10**18
ans = 0
for a in A:
if mx < a - mi:
ans = 0
mx = a - mi
if mx == a - mi:
ans += 1
mi = min(mi, a)
print(ans)
| p03946 |
from collections import defaultdict
N,T=list(map(int,input().split(" ")))
A=list(map(int,input().split(" ")))
m=0
for i in range(1,N):
a=min(A[:i])
b=max(A[i:])
if b-a>m:
m=b-a
sub=defaultdict(lambda:0)
sub[str([a,b])]
elif b-a==m:
sub[str([a,b])]
c=list(sub.... | from collections import defaultdict
N,T=list(map(int,input().split(" ")))
A=list(map(int,input().split(" ")))
sub=defaultdict(lambda:0)
max1=A[0]
min1=A[0]
for i in range(N):
if A[i]>=max1>=min1:
max1=A[i]
sub[max1-min1]+=1
elif max1>=A[i]>=min1:
max1=A[i]
sub[max1-mi... | p03946 |
from collections import defaultdict
N, T = list(map(int, input().split()))
A = [int(x) for x in input().split()]
c = defaultdict(int)
for i in range(N - 1):
x = max(A[i + 1:])
c[x - A[i]] += 1
print((c[max(c)]))
| from collections import defaultdict
N, T = list(map(int, input().split()))
A = [int(x) for x in input().split()]
B = [0] * N
for i in range(N - 1):
a = A[N - i - 1]
B[i + 1] = max(B[i], a)
B = B[::-1]
c = defaultdict(int)
for i in range(N - 1):
c[B[i] - A[i]] += 1
print((c[max(c)]))
| p03946 |
from collections import defaultdict
N, T = list(map(int, input().split()))
A = [int(x) for x in input().split()]
B = [0] * N
for i in range(N - 1):
a = A[N - i - 1]
B[i + 1] = max(B[i], a)
B = B[::-1]
c = defaultdict(int)
for i in range(N - 1):
c[B[i] - A[i]] += 1
print((c[max(c)]))
| from itertools import accumulate
from collections import defaultdict
N, T = list(map(int, input().split()))
A = [int(x) for x in input().split()]
B = [x for x in accumulate(A[::-1], max)][::-1]
c = defaultdict(int)
for i in range(N - 1):
c[B[i] - A[i]] += 1
print((c[max(c)])) | p03946 |
[n,t]=list(map(int,input().split()))
alist=list(map(int,input().split()))
salist=[alist[1]-alist[0]]
for i in range(1,n-1):
saisho=min(alist[0:i])
salist.append(alist[i+1]-saisho)
saidai=max(salist)
kaisu=salist.count(saidai)
print(kaisu) | [n,t]=list(map(int,input().split()))
alist=list(map(int,input().split()))
salist=[alist[1]-alist[0]]
saisho=min(alist[0],alist[1])
for i in range(1,n-1):
saisho=min(saisho,alist[i])
salist.append(alist[i+1]-saisho)
saidai=max(salist)
kaisu=salist.count(saidai)
print(kaisu) | p03946 |
# -*- coding: utf-8 -*-
#############
# Libraries #
#############
import sys
input = sys.stdin.readline
import math
#from math import gcd
import bisect
import heapq
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache
###... | # -*- coding: utf-8 -*-
#############
# Libraries #
#############
import sys
input = sys.stdin.readline
import math
#from math import gcd
import bisect
import heapq
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache
###... | p03946 |
N,T=list(map(int,input().split()))
A=tuple(map(int,input().split()))
B={}
for i in range(1,N):
tmp=A[i]-min(A[:i])
if tmp not in B:
B[tmp]=1
else:
B[tmp]+=1
maxB=max(B)
print((B[maxB])) | N,T=list(map(int,input().split()))
A=tuple(map(int,input().split()))
x=[0]*N
x[0]=A[0]
for i in range(1,N):
x[i]=min(x[i-1],A[i])
B={}
for i in range(1,N):
tmp=A[i]-x[i-1]
if tmp<0:
continue
if tmp not in B:
B[tmp]=1
else:
B[tmp]+=1
d=list(B.items())
d.sort(reverse=True)
print((d[... | p03946 |
# -*- coding: utf-8 -*-
import sys
from collections import deque
from collections import defaultdict
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N, T = list(map(int, readline().split()))
A = list(map(int,readline().split()))
B = sorted(A,reverse =... | # -*- coding: utf-8 -*-
import sys
from collections import deque
from collections import defaultdict
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N, T = list(map(int, readline().split()))
A = list(map(int,readline().split()))
### セグメント木
# 0-inde... | p03946 |
n, t = list(map(int, input().split()))
a = list(map(int, input().split()))
vm = a[n - 1]#数列を右から見た時の最大値
d = dict()
for i in range(n - 2, -1, -1):
if a[i] > vm:
vm = a[i]
else:
df = vm - a[i]
d[df] = d.get(df, 0) + 1
df_cnt = sorted(list(d.items()), key = lambda x:x[0], rever... | n, t = list(map(int, input().split()))
a = list(map(int, input().split()))
vm = a[n - 1]#数列を右から見た時の最大値
dfm = 0
cnt = 0
for i in range(n - 2, -1, -1):
if a[i] > vm:
vm = a[i]
else:
df = vm - a[i]
if dfm < df:
dfm = df
cnt = 1
elif dfm == df:
... | p03946 |
def main():
from heapq import heappush
inf = 1 << 30
N, T = list(map(int, input().split()))
*A, = list(map(int, input().split()))
h = [inf]
ma = -1
cnt = 0
for x in A:
d = x - h[0]
if ma < d:
ma = d
cnt = 1
elif ma == d:
... | def main():
N, T = list(map(int, input().split()))
*A, = list(map(int, input().split()))
mi = A[0]
d_ma = -1
cnt = 0
for x in A:
d = x - mi
if d_ma < d:
d_ma = d
cnt = 1
elif d_ma == d:
cnt += 1
if mi > x:
... | p03946 |
# -*- coding: utf-8 -*-
"""
参考:https://atcoder.jp/contests/abc047/submissions/4077573
"""
import sys
import re
from collections import deque, Counter, defaultdict
from math import sqrt, hypot, factorial, pi, sin, cos, radians
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bise... | # -*- coding: utf-8 -*-
"""
参考:https://atcoder.jp/contests/abc047/submissions/4077573
"""
import sys
def input(): return sys.stdin.readline().strip()
def MAP(): return list(map(int, input().split()))
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD =... | p03946 |
from collections import Counter
N, T, *A = list(map(int, open(0).read().split()))
mi = A[0]
ma = 0
B = Counter()
for a in A[1:]:
b = a - mi
B[b] += 1
ma = max(ma, b)
mi = min(mi, a)
print((B[ma]))
| N, T, A0, *A = list(map(int, open(0).read().split()))
ma, mi = 0, A0
B = {}
for a in A:
b = a - mi
B[b] = B.get(b, 0) + 1
ma, mi = max(ma, b), min(mi, a)
print((B[ma])) | p03946 |
from collections import deque,Counter
N,T=list(map(int, input().split()))
A=list(map(int, input().split()))
q=deque(A)
max_n=max(q)
b=[]
for i in range(N-1):
q.popleft()
if A[i]==max_n:
max_n=max(q)
b.append(max_n-A[i])
C=Counter(b)
max_key=max(C.keys())
print(C[max_key]) | from collections import Counter
N,T=list(map(int, input().split()))
A=list(map(int, input().split()))
A_r=[None for i in range(N)]
n=0
for i in range(N-1,-1,-1):
n=max(A[i],n)
A_r[i]=n
B=[]
for i in range(N-1):
B.append(A_r[i+1]-A[i])
C=Counter(B)
print(C[max(B)]) | p03946 |
from collections import Counter
N,T = list(map(int, input().split()))
A = list(map(int, input().split()))
a_min = float("inf")
a_max = 0
a_diff = 0
counter = Counter([])
for a in A:
hasModefied = False
if a_min > a:
a_min = a
a_max = a
if a_max < a:
a_max = a
... | N,T = list(map(int, input().split()))
A = list(map(int, input().split()))
a_min = float("inf")
a_max = 0
a_diff = 0
ans = 0
a_diff = -1
for a in A:
hasModefied = False
if a_min > a:
a_min = a
a_max = a
if a_max < a:
a_max = a
hasModefied = True
... | p03946 |
from collections import Counter
import sys
sdin = sys.stdin.readline
n,t = list(map(int, sdin().split()))
a = list(map(int, sdin().split()))
# iまででの最高と最低
diff_list = [] # iを含むiまでの最低
max_list = [] # iを含まないiからの最高
mini = max(a)
maxi = max(a)
# iまでの最低と最高を更新
for i in range(n-1):
if a[i] < mini:
... | from collections import Counter
import sys
sdin = sys.stdin.readline
n,t = list(map(int, sdin().split()))
a = list(map(int, sdin().split()))
# iまででの最高と最低
diff_list = [] # iを含むiまでの最低
max_list = [] # iを含まないiからの最高
mini = max(a)
maxi = a[-1]
max_list = [a[-1]]
for i in range(n-1,0,-1):
if a[i] > maxi:... | p03946 |
n,t,*a=list(map(int,open(0).read().split()))
amin = [10**9+1] + [0]*n
amax = [0]*(n+1)
for i,x in enumerate(a):
amin[i+1] = min(amin[i],x)
for i,x in enumerate(a[::-1]):
amax[i+1] = max(amax[i],x)
d = max(i-j for i,j in zip(amax[-2::-1], amin[1:]))
dp = [[0]*(n+1) for _ in range(n+1)]
for i in range(n):
fo... | from itertools import*;_,a=open(0);*a,=list(map(int,a.split()));c=[x-y for x,y in zip(a,accumulate(a,min))];print((c.count(max(c)))) | p03946 |
_,_,*a=list(map(int,open(0).read().split()));c=[x-y for x,y in zip(a,__import__("itertools").accumulate(a,min))];print((c.count(max(c)))) | def solve():
_,_,*a=list(map(int,open(0).read().split()));c=[x-y for x,y in zip(a,__import__("itertools").accumulate(a,min))];print((c.count(max(c))))
if __name__=="__main__":solve() | p03946 |
# -*- coding: utf-8 -*-
n,t = list(map(int, input().split()))
a = list(map(int, input().split()))
l,r = 0,0
diff = 0
num = 0
lp = 0
for l in range(n):
if(a[lp]<a[l]):
pass
else:
for r in range(l+1,n):
#print(l,r)
if(a[r]-a[l]>diff):
lp =... | # -*- coding: utf-8 -*-
n,t = list(map(int, input().split()))
a = list(map(int, input().split()))
m = 10**9+1
num = 0
diff = 0
for i in range(n):
if(a[i]<m):
m = a[i]
if(a[i]-m > diff):
diff = a[i]-m
num = 1
elif(a[i]-m == diff):
num += 1
print(num) | p03946 |
N, T = list(map(int, input().split()))
A = list(map(int, input().split()))
B = []
for i in range(1, N):
B.append(A[i]-min(A[0:i]))
result = B.count(max(B))
print(result) | N, T = list(map(int, input().split()))
A = list(map(int, input().split()))
B = []
Amin = A[0]
for i in range(1, N):
if A[i] < Amin:
Amin = A[i]
else:
B.append(A[i] - Amin)
result = B.count(max(B))
print(result) | p03946 |
N,T = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
maxdiff = 0
ct = 0
for i in range(N):
for j in range(i+1,N):
if A[j]-A[i] > maxdiff:
maxdiff = A[j]-A[i]
ct = 1
elif A[j]-A[i] == maxdiff:
ct += 1
print(ct) | N,T = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
maxdiff = 0
ct = 0
mintmp = float("inf")
for A_i in A:
mintmp = min(A_i,mintmp)
diff = A_i - mintmp
if diff > maxdiff:
maxdiff = diff
ct = 1
elif diff == maxdiff:
ct += 1
print(ct) | p03946 |
from collections import Counter
n,t=list(map(int,input().split()))
*a,=list(map(int,input().split()))
m=[None]*n
used=[False]*n
for i in range(n)[::-1]:
if i==n-1:
m[i]=a[i]
else:
m[i]=max(m[i+1],a[i])
c=Counter([m[i]-a[i] for i in range(n)])
print((c[max(c.keys())]))
| from operator import add
from collections import defaultdict
class SegTree():
def __init__(self, N, e, operator_func=add):
self.e = e # 単位元
self.size = N
self.node = [self.e] * (2*N)
self.operator_func = operator_func # 処理(add or xor max minなど)
def set_list(self, l):
... | p03946 |
N,T=list(map(int,input().split()))
A=list(map(int,input().split()))
MAX=[A[-1]]
for i in range(N-2,-1,-1):
MAX.append(max(MAX[-1],A[i]))
MAX=MAX[::-1]
SABUN=[MAX[i]-A[i] for i in range(N)]
#print(MAX)
#print(SABUN)
MAXSA=max(SABUN)
SEG=[]
for i in range(N):
if SABUN[i]==MAXSA:
SEG... | N,T=list(map(int,input().split()))
A=list(map(int,input().split()))
MAX=[A[-1]]
for i in range(N-2,-1,-1):
MAX.append(max(MAX[-1],A[i]))
MAX=MAX[::-1]
SABUN=[MAX[i]-A[i] for i in range(N)]
#print(MAX)
#print(SABUN)
MAXSA=max(SABUN)
ANS=0
for i in range(N):
if SABUN[i]==MAXSA:
ANS+... | p03946 |
N,T = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
ind = 0
rieki = []
if N == 2:
print((1))
exit()
sairi = 0
while True:
ma = max(a[ind+1:N])
kioku = ind+1
ind = a.index(ma)
if kioku != ind:
mi = min(a[kioku:ind])
if ma - mi > sairi:
... | N,T = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
ans = []
mi = 10**9
for i in range(N):
mi = min(mi,a[i])
ans.append(a[i]-mi)
print((ans.count(max(ans)))) | p03946 |
class SegmentTree():
"""
update, get を提供するSegmentTree
Attributes
----------
__n : int
葉の数。2 ^ i - 1
__dot :
Segment function
__e: int
単位元
__node: list
Segment Tree
"""
def __init__(self, A, dot, e):
"""
Parameters
... | def main():
import sys
readline = sys.stdin.readline
# readlines = sys.stdin.readlines
N, T = list(map(int, input().split()))
A = list(map(int, readline().split()))
L = float('inf')
cnt = 0
profit = 0
for a in A:
if a - L > profit:
cnt = 1
... | p03946 |
N,T = list(map(int,input().split()))
List = list(map(int,input().split()))
dic = {}
min = List[0]
for i in range(N):
if List[i]<min:
min = List[i]
if List[i]-min not in dic:
dic[List[i]-min] = 1
else:
dic[List[i]-min] += 1
dic2 = sorted(list(dic.items()), reverse=True)
Answer = dic2[0][1]
... | n, t = list(map(int, input().split()))
*a, = list(map(int, input().split()))
purchase = a[0]
profit = []
for i in range(len(a)):
profit.append(a[i] - purchase)
if a[i] < purchase:
purchase = a[i]
profit.sort()
Answer = profit.count(profit[-1])
print(Answer) | p03946 |
N,T = list(map(int,input().split()))
src = list(map(int,input().split()))
minv = src[0]
maxp = ans = 0
for i in range(1,N):
profit = src[i] - minv
if profit == maxp:
ans += 1
elif profit > maxp:
maxp = profit
ans = 1
minv = min(minv, src[i])
print(ans) | N,T = list(map(int,input().split()))
src = list(map(int,input().split()))
mincost = src[0]
maxgain = 0
sell = 0
buy = 1
for a in src[1:]:
if a < mincost:
mincost = a
buy = 1
elif a == mincost:
buy += 1
elif a > mincost + maxgain:
maxgain = a - mincost
... | p03946 |
N,T = list(map(int,input().split()))
src = list(map(int,input().split()))
mincost = src[0]
maxgain = 0
sell = 0
buy = 1
for a in src[1:]:
if a < mincost:
mincost = a
buy = 1
elif a == mincost:
buy += 1
elif a > mincost + maxgain:
maxgain = a - mincost
... | N,T = list(map(int,input().split()))
A = list(map(int,input().split()))
mn = A[0]
gain = 0
ans = 1
for a in A[1:]:
if a < mn:
mn = a
continue
if a-mn == gain:
ans += 1
elif a-mn > gain:
gain = a-mn
ans = 1
print(ans) | p03946 |
N, T = list(map(int, input().split()))
A = list(map(int, input().split()))
max_bef = 0
cnt = 0
A_min = A[0]
for i in range(1,N):
tmp = A[i] - A_min
if max_bef < tmp:
max_bef = tmp
cnt = 0
if max_bef == tmp:
cnt += 1
A_min = min(A_min, A[i])
print(cnt)
| def main():
N, T = list(map(int, input().split()))
A = list(map(int, input().split()))
min_A = float('inf')
cnt = 0
profit = 0
for i in range(N):
min_A = min(min_A,A[i])
diff_A = A[i] - min_A
if profit == diff_A:
cnt += 1
elif profit < diff_... | p03946 |
from collections import defaultdict
n, t = list(map(int, input().split()))
A = list(map(int, input().split()))
MAX_S = []
max_tmp = 0
for a in A[::-1]:
if max_tmp < a:
max_tmp = a
MAX_S.append(max_tmp)
MAX_S = MAX_S[::-1]
cnt = defaultdict(int)
for a, s in zip(A, MAX_S):
cnt[s-a] += 1
... | from collections import defaultdict
n, _ = list(map(int, input().split()))
A = list(map(int, input().split()))
MAX_S = []
max_s = 0
for a in A[::-1]:
if max_s < a:
max_s = a
MAX_S.append(max_s)
MAX_S = MAX_S[::-1]
cnt = defaultdict(int)
for a, s in zip(A, MAX_S):
cnt[s-a] += 1
print... | p03946 |
# -*- coding: utf-8 -*-
n,t = list(map(int, input().split()))
apple_price = list(map(int, input().split()))
price_diff = []
for i in range(n):
if(i <= n-2):
if(apple_price[i] < apple_price[i+1]):
for j in range(i,n):
diff = apple_price[j] - apple_price[i]
... | # -*- coding: utf-8 -*-
n,t = list(map(int, input().split()))
apple_price = list(map(int, input().split()))
price_diff = []
now_min = 10**9
for i in range(n):
if(now_min > apple_price[i]):
now_min = apple_price[i]
else:
price_diff.append(apple_price[i] - now_min)
if(price_dif... | p03946 |
N,T=list(map(int,input().split()))
A=list(map(int,input().split()))
import collections
table=collections.defaultdict(set)
table2=collections.defaultdict(set)
tmp=0
for i in range(N-1):
for j in range(i+1,N):
table[A[j]-A[i]].add(i)
table2[A[j]-A[i]].add(j)
tmp=max(tmp,A[j]-A[i])
print((min(... | N,T=list(map(int,input().split()))
A=list(map(int,input().split()))
import heapq
import collections
hq=[]
heapq.heapify(hq)
heapq.heappush(hq,A[0])
tmp=0
table=collections.defaultdict(int)
for i in range(1,N):
j=heapq.heappop(hq)
table[A[i]-j]+=1
tmp=max(tmp,A[i]-j)
heapq.heappush(hq,j)
heap... | p03946 |
N, T = list(map(int, input().split()))
A = [int(i) for i in input().split()]
c = 0
MAX = 0
for i in range(N-1):
a1 = min(A[:i+1])
a2 = A[i+1]
if MAX == a2 - a1:
c += 1
elif MAX < a2 - a1:
MAX = a2 - a1
c = 1
print(c)
| N, T = list(map(int, input().split()))
A = [int(i) for i in input().split()]
c = 0
MAX = 0
a1 = A[0]
for i in range(N-1):
if A[i] <= a1:
a1 = A[i]
a2 = A[i+1]
if MAX == a2 - a1:
c += 1
elif MAX < a2 - a1:
MAX = a2 - a1
c = 1
print(c)
| p03946 |
import sys
import heapq
def v():
N,T=tuple(map(int,sys.stdin.readline().split()))
A=list(map(int,sys.stdin.readline().split()))
d=[]
for i,a in enumerate(A[:-1]):
b=max(A[i+1:])
c=b-a if b>a else 0
d.append(-c)
heapq.heapify(d)
res,x=1,heapq.heappop(d)
whi... | import sys
import heapq
def v():
N,T=tuple(map(int,sys.stdin.readline().split()))
A=list(map(int,sys.stdin.readline().split()))
ma=0
d=[]
heapq.heapify(d)
for a in reversed(A):
if a<ma:heapq.heappush(d,a-ma)
else:ma=a
res,x=1,heapq.heappop(d)
while len(d)>0:
... | p03946 |
# coding: utf-8
# Your code here!
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
#n = int(input())
n,t = [int(i) for i in readline().split()]
a = [10**9+1]+[int(i) for i in readline().split()]
"""
gain = 0
m = 0
maxid = []
minid = []
memo = {}
for i in range(n-1,-1,-1):
... | # coding: utf-8
# Your code here!
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
#n = int(input())
n,t = [int(i) for i in readline().split()]
a = [int(i) for i in readline().split()]
m = gain = 0
ans = 0
for ai in reversed(a):
m = max(ai,m)
if gain < m-ai:
ans ... | p03946 |
iN,iT = [int(_) for _ in input().split()]
aA = [int(_) for _ in input().split()]
iL = len(aA)
aMaxD = [0]
aMin=[aA[0]]
iV = 0
def checkMax(aMaxD,aMin,iB):
iMaxD = 0
for iMin in aMin:
iMaxD = max(iMaxD,iB - iMin)
if aMaxD[0] < iMaxD:
aMaxD = [iMaxD]
elif aMaxD[0] == iMaxD:... |
iN,iT = [int(_) for _ in input().split()]
aA = [int(_) for _ in input().split()]
iL = len(aA)
aMaxD = [0]
iMin = aA[0]
iV = 0
def checkMax(aMaxD,iMaxD):
if aMaxD[0] < iMaxD:
aMaxD = [iMaxD]
elif aMaxD[0] == iMaxD:
aMaxD.append(iMaxD)
return aMaxD
for i in range(1,iL):
... | p03946 |
def 解():
iN,iT = [int(_) for _ in input().split()]
aA = [int(_) for _ in input().split()]
iL = len(aA)
aMaxD = [0]
iMin = aA[0]
iV = 0
def checkMax(aMaxD,iMaxD):
if aMaxD[0] < iMaxD:
aMaxD = [iMaxD]
elif aMaxD[0] == iMaxD:
aMaxD.append(i... | def 解():
iN,iT = [int(_) for _ in input().split()]
aA = [int(_) for _ in input().split()]
aMaxD = [0]
iMin = aA[0]
iV = 0
def checkMax(aMaxD,iMaxD):
if aMaxD[0] < iMaxD:
aMaxD = [iMaxD]
elif aMaxD[0] == iMaxD:
aMaxD.append(iMaxD)
ret... | p03946 |
def main():
N, T = list(map(int, input().split(' ')))
A = list(map(int, input().split(' ')))
target_list = list()
price_buy, town_num_buy = A[N - 1], 1
price_sell, town_num_sell = A[N - 1], 1
for t in range(N - 2, -1, -1):
price = A[t]
if price < price_buy:
p... | def main():
N, T = list(map(int, input().split(' ')))
A = list(map(int, input().split(' ')))
score_list = [0 for _ in range(N)]
min_price = A[0]
for i in range(N):
a = A[i]
score_list[i] = a - min_price
min_price = min(a, min_price)
max_score = max(score_list)
... | p03946 |
N=int(input().split(" ")[0])
put=input().split(" ")
A=[]
for i in range(N):
A.append(int(put[i]))
p=[A[0]]
for i in range(1,N-1):
if A[i-1]<A[i] and A[i]>A[i+1]:
p.append(A[i])
elif A[i-1]>A[i] and A[i]<A[i+1]:
p.append(A[i])
p.append(A[N-1])
x=0
t=1
for i in range(len(p)... | nt=input().split(" ")
N=int(nt[0])
T=int(nt[1])
a=input().split(" ")
int_a=[]
maxlist=[]
for i in range(N):
int_a.append(int(a[i]))
reva=int_a
reva.reverse()
max=0
for i in range(N):
if reva[i]>max:
max=reva[i]
maxlist.append(max)
maxlist.reverse()
int_a.reverse()
max=0
... | p03946 |
n,t=list(map(int,input().split()))
a=list(map(int,input().split()))
max=0
ans=1
for i in range(len(a)-1):
for j in range(i+1,len(a)):
if (a[j]-a[i])>max:
max=a[j]-a[i]
ans=1
elif (a[j]-a[i])==max:
ans+=1
else:
pass
print(ans)
| n,t=list(map(int,input().split()))
a=list(map(int,input().split()))
max=0
min=1000000000000000000000000000000000000
ans=1
for i in range(len(a)-1):
if a[i]<min:
min=a[i]
elif min==a[i] or max==a[i]-min:
ans+=1
elif max<a[i]-min:
ans=1
max=a[i]-min
if a[len(a)-1]-min==max:
ans+=1
p... | p03946 |
n, t = list(map(int, input().split(" ")))
list_a = list(map(int, input().split(" ")))
list_profit = []
for i, a in enumerate(list_a[:-1]):
max_price = max(list_a[(i+1):])
if a < max_price:
list_profit.append(max_price - a)
else:
list_profit.append(0)
max_profit = max(list_profit)
print((list_pro... | n, t = list(map(int, input().split(" ")))
list_a = list(map(int, input().split(" ")))
list_profit = []
min_price = list_a[0]
for a in list_a:
if min_price < a:
list_profit.append(a - min_price)
else:
list_profit.append(0)
min_price = a
max_profit = max(list_profit)
print((list_profit.count(ma... | p03946 |
class SEGTree:
def __init__(self,n):
self.Unit=0
i=1
while(i<n):
i*=2
self.SEG=[self.Unit]*(2*i-1)
self.d=i
def update(self,i,x):
i+=self.d-1
self.SEG[i]=x
while i>0:
i=(i-1)//2
self.SEG[i]=max(self.... | N,T=list(map(int,input().split()))
A=list(map(int,input().split()))
ans=0
max_=0
B=[0]*N
for i in reversed(list(range(N))):
B[i]=max(B[i],max_-A[i])
max_=max(max_,A[i])
m=max(B)
print((B.count(m))) | p03946 |
# ans = 売る可能性がある場所の数 = 売って利益が最大値になる可能性がある場所
# Tは関係ない
N,T=list(map(int,input().split()))
A=list(map(int,input().split()))
# 売る場所を一つず右にずらす
# それより前の場所の最安値を持っておく
# 差分のmaxvalを満たす回数をカウント、maxvalが更新されたら回数は1に戻す
INF=10**9+1
maxval=0
minval=INF
ans=0
for i in range(1,len(A)):
minval=min(A[i-1],minval)
diff=... | import sys
readline = sys.stdin.readline
# そこまでの最小値を記録する
# 最小値との差が最大になった時点で、その値を記録し、1を計上
# 最小値との差がこれまでの最大値と同じ場合は+1を計上
# 最小値との差の最大値が更新された場合はまた1から計上
# Tは関係ない
N,T = list(map(int,readline().split()))
A = list(map(int,readline().split()))
minval = 10 ** 9 + 1 # そこまでの最小値
maxdiff = 0 # そこまでの差の最大値
ans = 0
for... | p03946 |
from sys import stdin, stdout
from collections import deque, defaultdict
from functools import lru_cache
rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: list(map(int, stdin.readline().split()))
INF, NINF = float('inf'), float('-inf')
def main():
MOD = 10**9 + 7
x = []... | from sys import stdin, stdout
from collections import deque, defaultdict
from functools import lru_cache
rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: list(map(int, stdin.readline().split()))
INF, NINF = float('inf'), float('-inf')
def main():
MOD = 10**9 + 7
x = []... | p03178 |
def read_int():
return int(input().strip())
def read_ints():
return list(map(int, input().strip().split(' ')))
def solve():
"""
_ _
dp[i][j][one_of_previous_number_is_lower] = count of remainder j up to i-th digit, 0 <= j < D
dp[i][(j+digit)%D][True] += dp[i-1][j][True] ... |
def read_int():
return int(input().strip())
def read_ints():
return list(map(int, input().strip().split(' ')))
def solve():
"""
_ _
dp[i][j][one_of_previous_number_is_lower] = count of remainder j up to i-th digit, 0 <= j < D
dp[i][(j+digit)%D][True] += dp[i-1][j][True] ... | p03178 |
K = int(eval(input()))
D = int(eval(input()))
MOD = 10**9 + 7
dp = [[[0]*D for _ in range(2)] for _ in range(int(len(str(K)))+1)]
dp[0][0][0] = 1
for digit in range(int(len(str(K)))):
for smaller_flg in [0,1]:
for mod_d in range(D):
lim = 9 if smaller_flg else int(str(K)[digit])
... | K = int(eval(input()))
D = int(eval(input()))
MOD = 10**9 + 7
dp = [[[0]*D for _ in range(2)] for _ in range(int(len(str(K)))+1)]
dp[0][0][0] = 1
for digit in range(int(len(str(K)))):
for smaller_flg in [0,1]:
lim = 9 if smaller_flg else int(str(K)[digit])
for digit_num in range(lim+1):
... | p03178 |
K = int(eval(input()))
D = int(eval(input()))
MOD = 10**9 + 7
dp = [[[0]*(int(len(str(K)))+1) for _ in range(D)] for _ in range(2)]
dp[0][0][0] = 1
for digit in range(int(len(str(K)))):
for smaller_flg in [0,1]:
lim = 9 if smaller_flg else int(str(K)[digit])
for digit_num in range(lim+1)... | K = int(eval(input()))
D = int(eval(input()))
MOD = 10**9 + 7
dp = [[[0]*D for _ in range(2)] for _ in range(int(len(str(K)))+1)]
dp[0][0][0] = 1
# 外側の要素から外側のループに置くと参照が速くなる
for digit in range(int(len(str(K)))):
for smaller_flg in [0,1]:
lim = 9 if smaller_flg else int(str(K)[digit])
for... | p03178 |
K, = list(map(int, input().split()))
D, = list(map(int, input().split()))
N = len(str(K))
M = 10**9+7
dp = [[0]*D for _ in range(N+1)]
dp2 = [[0]*D for _ in range(N+1)]
dp[0][0] = 1
dp2[0][0] = 1
for i in range(1, N+1):
Ki = K%10
K //= 10
for j in range(D):
for k in range(10):
... | K, = list(map(int, input().split()))
D, = list(map(int, input().split()))
N = len(str(K))
M = 10**9+7
dp = [[0]*D for _ in range(N+1)]
dp2 = [[0]*D for _ in range(N+1)]
dp[0][0] = 1
dp2[0][0] = 1
for i in range(1, N+1):
Ki = K%10
K //= 10
for j in range(D):
for k in range(10):
... | p03178 |
# -*- coding: utf-8 -*-
#O[|w|]:|w|???????´¢???????????????????????????
#??\????????¨??\?°????????????´??????????????¨????????????????????????????????????nx[i]????????????????¨????
#???????????????????´¢??§?????????????????±???,????´¢??????????????¨??????????????¨??????,?????????????´¢??????
def kmpTable(w):
l... | def kmpTable(w):
lw = len(w)
nx = [-1] * (lw + 1)
j = -1
for i in range(lw):
while j >= 0 and w[i] != w[j]:
j = nx[j]
j += 1
nx[i + 1] = j
return nx
def kmpSearch(s, w):
ls = len(s)
start = 0
w_idx = 0
ret = []
nx = kmpTable(w)... | p02248 |
bus = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
for i in range(eval(input())):
s, t = list(map(int, input().split()))
if s>5:
print(" ".join(map(str, bus[s:bus.index(t, s)+1])))
else:
if s<t:
print(" ".join(map(str, range(s, t+1))))
... | bus = "0123456789543210123456789"
rbus = "543210"
for i in range(eval(input())):
s, t = input().split()
if t<s<'6':
left = rbus.find(s, 0)
right = rbus.find(t, left)
print(" ".join(rbus[left:right+1]))
else:
left = bus.find(s, 0)
right = bus.find(t, left)
... | p00140 |
import copy
def can_empty(A,y,x):
A[y][x],A[y][x+1] = A[y][x+1],A[y][x]
num = sum(W-a.count(".") for a in A)
while 1:
# Fall processing
for w in range(W):
seq = ("".join(A[h][w] for h in range(H))).replace(".","")
seq += "."*(H-len(seq))
for h i... | import copy
def can_empty(A,y,x):
A[y][x],A[y][x+1] = A[y][x+1],A[y][x]
num = sum(W-a.count(".") for a in A)
while 1:
# Fall processing
for w in range(W):
seq = ("".join(A[h][w] for h in range(H))).replace(".","")
seq += "."*(H-len(seq))
for h i... | p01349 |
N=int(eval(input()))
A=[int(i) for i in input().split()]
def Check(K):
stack=[]
n=A[0]
for i in range(1,N):
if A[i-1]<A[i]:
n=A[i]
else:
if K==1:
return False
while n>A[i]:
if stack:
if stack[-1][0]==n:
stack.pop()
n-=1
... | N=int(eval(input()))
A=[int(i) for i in input().split()]
def Check(K):
stack=[]
n=A[0]
for i in range(1,N):
if A[i-1]<A[i]:
n=A[i]
else:
if K==1:
return False
n=A[i]
while True:
l=0
if stack:
l=stack[-1][0]
if l>n:
... | p03202 |
def main():
import heapq
n = int(eval(input()))
a = list(map(int, input().split()))
for i in range(n-1):
if a[i] >= a[i+1]:
break
else:
print((1))
return
h = []
heapq.heapify(h)
kind = 1
length = 0
d = dict()
for i in a:
... | def main():
import heapq
n = int(eval(input()))
a = list(map(int, input().split()))
for i in range(n-1):
if a[i] >= a[i+1]:
break
else:
print((1))
return
h = []
heapq.heapify(h)
kind = 1
length = 0
d = dict()
for i in a:
... | p03202 |
N = int(eval(input()))
A = list(map(int,input().split()))
if A == sorted(A) and len(A) == len(set(A)):
print((1))
exit(0)
def check(X):
idx = [0]
ltr = [0]
for a in A:
if idx[-1] < a:
idx.append(a)
ltr.append(0)
else:
while True:
while idx[-1] > a:
... | N = int(eval(input()))
A = list(map(int,input().split()))
if A == sorted(A) and len(A) == len(set(A)):
print((1))
exit(0)
def check(X):
idx = [0]
ltr = [0]
for a in A:
if idx[-1] < a:
idx.append(a)
ltr.append(0)
else:
while True:
while idx[-1] > a:
... | p03202 |
import sys
input = sys.stdin.readline
import heapq
from collections import defaultdict
N=int(eval(input()))
A=[0]+list(map(int,input().split()))
def Nextstring(nowlength,nextlength):
if nextlength>nowlength:
while -USELIST[0]>nowlength:
dis=-heapq.heappop(USELIST)
del N... | def main():
import sys
input = sys.stdin.readline
import heapq
from collections import defaultdict
N=int(eval(input()))
A=[0]+list(map(int,input().split()))
def Nextstring(nowlength,nextlength):
if nextlength>nowlength:
while -USELIST[0]>nowlength:
... | p03202 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.