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 stringlengths 1 5 | memory stringlengths 1 7 | code_size stringlengths 1 6 | code stringlengths 1 539k |
|---|---|---|---|---|---|---|---|---|---|---|---|
s578175401 | p02537 | u602740328 | 1601267812 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 23592 | 938 | class SegTree(object):
def __init__(self,op,e,n,init_val):
self.num = 1<<(n-1).bit_length()
self.S = [e]*self.num*2
self.op = op
self.e = e
for i,v in enumerate(init_val): self.S[self.num+i] = v
for i in range(self.num-1,0,-1):
self.S[i] = self.op(self.S[i*2], self.S[i*2+1])
de... |
s640597153 | p02537 | u602740328 | 1601267360 | Python | PyPy3 (7.3.0) | py | Runtime Error | 788 | 82644 | 929 | class SegTree(object):
def __init__(self,op,e,n,init_val):
self.num = 1<<(300000-1).bit_length()
self.S = [e]*self.num*2
self.op = op
self.e = e
for i,v in enumerate(init_val): self.S[self.num+i] = v
for i in range(self.num-1,0,-1):
self.S[i] = self.op(self.S[i*2], self.S[i*2+1])
def ... |
s267781979 | p02537 | u602740328 | 1601267298 | Python | PyPy3 (7.3.0) | py | Runtime Error | 718 | 82588 | 927 | class SegTree(object):
def __init__(self,op,e,n,init_val):
self.num = 1<<(300000-1).bit_length()
self.S = [e]*self.num*2
self.op = op
self.e = e
for i,v in enumerate(init_val): self.S[self.num+i] = v
for i in range(self.num-1,0,-1):
self.S[i] = self.op(self.S[i*2], self.S[i*2+1])
def ... |
s364765408 | p02537 | u692657167 | 1601262696 | Python | PyPy3 (7.3.0) | py | Runtime Error | 170 | 109488 | 222 | n, k, *al = map(int, open(0).read().split())
d = [0] * 300000
for a in al:
l = max(0, a-k)
r = min(a+k, 300000)
m = 0
for i in range(l, r+1):
m = max(m, d[i])
d[a] = max(d[a], m+1)
print(max(d)) |
s607297081 | p02537 | u520276780 | 1601260084 | Python | PyPy3 (7.3.0) | py | Runtime Error | 170 | 83532 | 960 |
## https://atcoder.jp/contests/abc170/submissions/14416787
import sys
input=sys.stdin.readline
class SegmentTree():
def __init__(self,n,init):
self.offset=2**((n-1).bit_length())
self.tree=[init]*(2*self.offset)
self.init=init
def update(self,pos,val):
pos+=self.offset
... |
s595124777 | p02537 | u520276780 | 1601260044 | Python | PyPy3 (7.3.0) | py | Runtime Error | 483 | 110308 | 951 | ## https://atcoder.jp/contests/abc170/submissions/14416787
import sys
input=sys.stdin.readline
class SegmentTree():
def __init__(self,n,init):
self.offset=2**((n-1).bit_length())
self.tree=[init]*(2*self.offset)
self.init=init
def update(self,pos,val):
pos+=self.offset
... |
s879811580 | p02537 | u520276780 | 1601259910 | Python | PyPy3 (7.3.0) | py | Runtime Error | 465 | 110984 | 964 |
## https://atcoder.jp/contests/abc170/submissions/14416787
import heapq
import sys
input=sys.stdin.readline
class SegmentTree():
def __init__(self,n,init):
self.offset=2**((n-1).bit_length())
self.tree=[init]*(2*self.offset)
self.init=init
def update(self,pos,val):
pos+=self.of... |
s321934481 | p02537 | u647999897 | 1601259409 | Python | PyPy3 (7.3.0) | py | Runtime Error | 2668 | 3531800 | 609 | def solve():
N,K = map(int,input().split())
A = [int(input()) for _ in range(N)]
A_max = max(A)
dp = [[0] * (A_max+1) for _ in range(N)]
dp[0][A[0]] = 1
for i in range(1,N):
for j in range(A_max+1):
dp[i][j] = dp[i-1][j]
mx = 0
if j == A[i]:
... |
s046484934 | p02537 | u758815106 | 1601245747 | Python | PyPy3 (7.3.0) | py | Runtime Error | 350 | 92664 | 2385 | #!/usr/bin/env python3
class SegTree:
def __init__(self, segfunc, e, v, init_val = None):
"""
segfunc: function 区間にしたい操作\n
e: Any 単位元\n
v: int or List 要素数か格納する配列\n
init_val: Any 初期値
"""
self.segfunc = segfunc
self.e = e
self.init_val = init_val... |
s053241857 | p02537 | u758815106 | 1601245541 | Python | PyPy3 (7.3.0) | py | Runtime Error | 351 | 92552 | 2363 | #!/usr/bin/env python3
class SegTree:
def __init__(self, segfunc, e, v, init_val = None):
"""
segfunc: function 区間にしたい操作\n
e: Any 単位元\n
v: int or List 要素数か格納する配列\n
init_val: Any 初期値
"""
self.segfunc = segfunc
self.e = e
self.init_val = init_val... |
s397892105 | p02537 | u805332733 | 1601236176 | Python | PyPy3 (7.3.0) | py | Runtime Error | 92 | 68704 | 2005 | #####segfunc#####
def segfunc(x, y):
return max(x, y)
#################
#####ide_ele#####
ide_ele = 0
#################
class SegTree:
"""
init(init_val, ide_ele): 配列init_valで初期化 O(N)
update(k, x): k番目の値をxに更新 O(logN)
query(l, r): 区間[l, r)をsegfuncしたものを返す O(logN)
"""
def __init__(self, init_val, segfunc, ... |
s957864071 | p02537 | u545368057 | 1601233087 | Python | PyPy3 (7.3.0) | py | Runtime Error | 130 | 88204 | 1416 | # セグメント木
# segment tree
import sys
input = sys.stdin.readline
class segmented_tree:
X_unit = 0
X_f = lambda self, a, b: max(a,b)
def __init__(self, N):
self.N = N
self.X = [self.X_unit] * (2*N)
def build(self, seq):
for i, x in enumerate(seq, self.N):
self.X... |
s654206768 | p02537 | u820729059 | 1601232915 | Python | PyPy3 (7.3.0) | py | Runtime Error | 89 | 68648 | 168 | n, k = input().split()
k = int(k) + 1
m = 0
f = int(input())
n = int(n) - 1;
for i in range(n):
s = int(input())
if abs(f-s) < k:
m += 1
f = s
print(m)
|
s071766390 | p02537 | u820729059 | 1601232766 | Python | PyPy3 (7.3.0) | py | Runtime Error | 82 | 68728 | 167 | n, k = input().split()
k = int(k) + 1
m = 0
f = int(input())
n = int(n) + 1;
for i in range(n):
s = int(input())
if abs(f-s) < k:
m += 1
f = s
print(m) |
s895975043 | p02537 | u820729059 | 1601232711 | Python | PyPy3 (7.3.0) | py | Runtime Error | 83 | 68680 | 158 | n, k = input().split()
k = int(k) + 1
m = 0
f = int(input())
n = int(n) + 1;
for i in range(n):
s = int(input())
if abs(f-s) < k:
m += 1
f = s |
s955542496 | p02537 | u888337853 | 1601232415 | Python | Python (3.8.2) | py | Runtime Error | 2207 | 36856 | 5424 | import typing
import sys
# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue
# import numpy as np
# sys.setrecursionlimit(10000001)
INF = 10 ** 16
# MOD = 10 ** 9 + 7
MOD... |
s068071442 | p02537 | u888337853 | 1601232406 | Python | PyPy3 (7.3.0) | py | Runtime Error | 545 | 116904 | 5424 | import typing
import sys
# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue
# import numpy as np
# sys.setrecursionlimit(10000001)
INF = 10 ** 16
# MOD = 10 ** 9 + 7
MOD... |
s732618529 | p02537 | u576432509 | 1601227783 | Python | PyPy3 (7.3.0) | py | Runtime Error | 694 | 108732 | 2513 | class SegmentTree():
def __init__(self, n, oper, e):
self.n = n
self.oper = oper
self.e = e
self.log = (n - 1).bit_length()
self.size = 1 << self.log
self.data = [e] * (2 * self.size)
def update(self, k):
self.data[k] = self.oper(self.data[2 * k], self.data[2 * k + 1])
def build(self... |
s718806571 | p02537 | u576432509 | 1601227214 | Python | PyPy3 (7.3.0) | py | Runtime Error | 656 | 108992 | 2506 |
class SegmentTree():
def __init__(self, n, oper, e):
self.n = n
self.oper = oper
self.e = e
self.log = (n - 1).bit_length()
self.size = 1 << self.log
self.data = [e] * (2 * self.size)
def update(self, k):
self.data[k] = self.oper(self.data[2 * k], self.data[2 * k + 1])
def build(sel... |
s160195327 | p02537 | u792720861 | 1601226514 | Python | Python (3.8.2) | py | Runtime Error | 373 | 21736 | 331 | N,K = map(int, input().split())
A = [int(input()) for _ in range(N)]
ans = 0
def dfs(idx, lastB, length):
global ans
if idx == N:
ans = max(ans, length)
return
dfs(idx+1, lastB, length)
if abs(lastB-A[idx]) <= K:
dfs(idx+1, A[idx], length+1)
dfs(0, A[0], 1)
dfs(0, A[1], 0)
pr... |
s200716277 | p02537 | u156815136 | 1601225619 | Python | PyPy3 (7.3.0) | py | Runtime Error | 542 | 137400 | 2596 | #from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from math import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
... |
s628181178 | p02537 | u156815136 | 1601225483 | Python | PyPy3 (7.3.0) | py | Runtime Error | 468 | 98008 | 2568 | #from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from math import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
... |
s712142382 | p02537 | u156815136 | 1601225269 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 33652 | 2574 | #from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from math import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
... |
s767768933 | p02537 | u169138653 | 1601221438 | Python | PyPy3 (7.3.0) | py | Runtime Error | 994 | 120560 | 1521 | n,k=map(int,input().split())
class SegmentTree:
def __init__(self,n,ele):
self.ide_ele = ele
self.num =2**(n-1).bit_length()
self.seg=[self.ide_ele]*2*self.num
#####segfunc######
#クエリに応じて変える
def segfunc(self,x,y):
return max(x,y)
def init(self,init_val):
... |
s169534466 | p02537 | u189479417 | 1601218386 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 22592 | 2117 | #####segfunc#####
def segfunc(x, y):
return max(x, y)
#################
#####ide_ele#####
ide_ele = 0
#################
class SegTree:
"""
init(init_val, ide_ele): 配列init_valで初期化 O(N)
update(k, x): k番目の値をxに更新 O(logN)
query(l, r): 区間[l, r)をsegfuncしたものを返す O(logN)
"""
def __init__(self, init_... |
s403508696 | p02537 | u623819879 | 1601215181 | Python | PyPy3 (7.3.0) | py | Runtime Error | 653 | 147864 | 7522 | import sys,bisect,string,math,time,functools,random,fractions
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
from itertools import permutations,combinations,groupby
rep=range;R=range
def Golf():n,*t=map(int,open(0).read().split())
def I():return int(input())
def S_():return... |
s321916248 | p02537 | u358254559 | 1601213281 | Python | PyPy3 (7.3.0) | py | Runtime Error | 633 | 105076 | 1314 | n,k = map(int, input().split())
a=[int(input()) for i in range(n)]
ide_ele = 0
def segfunc(x, y):
return max(x,y)
class SegTree:
def __init__(self, init_val, segfunc, ide_ele):
n = len(init_val)
self.segfunc = segfunc
self.ide_ele = ide_ele
self.num = 1 << (n - 1).bit_length()... |
s191819779 | p02537 | u102655885 | 1601204506 | Python | Python (3.8.2) | py | Runtime Error | 433 | 21644 | 1246 | n, k = map(lambda x: int(x), input().split())
list_a = []
for _ in range(n):
list_a.append(int(input()))
memo = dict()
# i番目以降の要素からなるsublistの長さとして最長のものの長さを返す
def sublist_max_length(current_value, i):
# if (current_value, i) in memo.keys():
# return memo[(current_value, i)]
if i == n-1:
... |
s174051053 | p02537 | u216928054 | 1601195343 | Python | PyPy3 (7.3.0) | py | Runtime Error | 429 | 87360 | 4490 | #!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**6)
INF = 10 ** 9 + 1 # sys.maxsize # float("inf")
MOD = 10 ** 9 + 7
def debug(*x):
print(*x, file=sys.stderr)
def solve_0_WA(N, K, AS):
candidates = [[0]]
for i in range(1, N):
A = AS[i]
new_candidates = []
for c in can... |
s752758548 | p02537 | u729133443 | 1601191209 | Python | PyPy3 (7.3.0) | py | Runtime Error | 951 | 109440 | 145 | n,k,*a=map(int,open(0).read().split())
d=[0]*n
i=n
while i:i-=1;d[i]=max(d[j]for j in range(i,min(i+99,n))if abs(a[~i]-a[-j])<=k)+1
print(max(d)) |
s077310018 | p02537 | u738898077 | 1601189970 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 18580 | 1105 |
class SegTree:
X_unit = 0
X_f = max
def __init__(self, N):
self.N = N
self.X = [self.X_unit] * (N + N)
def build(self, seq):
for i, x in enumerate(seq, self.N):
self.X[i] = x
for i in range(self.N - 1, 0, -1):
self.X[i] = self.X_f(self.X[i << 1... |
s207180878 | p02537 | u738898077 | 1601189686 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 18476 | 1101 |
class SegTree:
X_unit = 0
X_f = max
def __init__(self, N):
self.N = N
self.X = [self.X_unit] * (N + N)
def build(self, seq):
for i, x in enumerate(seq, self.N):
self.X[i] = x
for i in range(self.N - 1, 0, -1):
self.X[i] = self.X_f(self.X[i << 1... |
s358473053 | p02537 | u197956883 | 1601189503 | Python | PyPy3 (7.3.0) | py | Runtime Error | 91 | 68720 | 2070 | import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
... |
s688143024 | p02537 | u729133443 | 1601189347 | Python | PyPy3 (7.3.0) | py | Runtime Error | 1302 | 275560 | 142 | d=[0]*6**8
n,k,*a=map(int,open(0).read().split()+d)
for i in range(n):d[i]=max(d[j]for j in range(i-99,i)if abs(a[i]-a[j])<=k)+1
print(max(d)) |
s273785105 | p02537 | u729133443 | 1601189248 | Python | PyPy3 (7.3.0) | py | Runtime Error | 133 | 110836 | 144 | d=[0]*6**8
n,k,*a=map(int,open(0).read().split())+d
for i in range(n):d[i]=max(d[j]for j in range(i-99,i+1)if abs(a[i]-a[j])<=k)+1
print(max(d)) |
s150206248 | p02537 | u729133443 | 1601189144 | Python | PyPy3 (7.3.0) | py | Runtime Error | 1227 | 109356 | 139 | n,k,*a=map(int,open(0).read().split())
d=[0]*n
for i in range(n):d[i]=max(d[j]for j in range(i-99,i+1)if abs(a[i]-a[j])<=k)+1
print(max(d)) |
s624719990 | p02537 | u729133443 | 1601189115 | Python | PyPy3 (7.3.0) | py | Runtime Error | 1200 | 120076 | 142 | n,k,*a=map(int,open(0).read().split())
d=[0]*6**8
for i in range(n):d[i]=max(d[j]for j in range(i-99,i+1)if abs(a[i]-a[j])<=k)+1
print(max(d)) |
s412302176 | p02537 | u729133443 | 1601188837 | Python | PyPy3 (7.3.0) | py | Runtime Error | 162 | 109184 | 150 | n,k,*a=map(int,open(0).read().split())
d=[1]*n
for i in range(n):d[i]=max((d[i],d[j]+1)[abs(a[i]-a[j])<=k]for j in range(max(0,i-99),i))
print(max(d)) |
s993878152 | p02537 | u391725895 | 1601188634 | Python | PyPy3 (7.3.0) | py | Runtime Error | 640 | 142104 | 963 | # Segment Treeを使う。一点更新,区間最大値
N, K = map(int, input().split())
seglen = 1 << 19
segtree = [0 for _ in range(seglen * 2)]
# segtree[seglen + i] = Bの最後の値に i を使う時のlongest len
def segset(ind, val):
segtree[ind] = val
ind //= 2
while ind != 0:
segtree[ind] = max(segtree[ind*2], segtree[ind*2 + 1])
... |
s205562856 | p02537 | u729133443 | 1601188633 | Python | PyPy3 (7.3.0) | py | Runtime Error | 207 | 109348 | 144 | n,k,*a=map(int,open(0).read().split())
d=[1]*n
for i in range(n):d[i]=max(d[j]for j in range(max(0,i-99),i)if abs(a[i]-a[j])<=k)+1
print(max(d)) |
s910660168 | p02537 | u437351386 | 1601186151 | Python | PyPy3 (7.3.0) | py | Runtime Error | 104 | 94424 | 935 | n,m=map(int,input().split())
#Union-Find木
#par[i]:iの親 deep[i]:iの深さ size[i]:iの大きさ
par=[i for i in range(n)]
deep=[1]*n
size=[1]*n
#親を見つける
def find(x):
if par[x]==x:
return x
else:
return find(par[x])
#二つのグループを統合する
def unite(x,y):
x=find(x)
y=find(y)
if x==y:
return
if deep[x]<deep[y]:
par[x... |
s865216010 | p02537 | u602500004 | 1601184418 | Python | PyPy3 (7.3.0) | py | Runtime Error | 2211 | 172488 | 980 | import math
import sys
import os
sys.setrecursionlimit(10**7)
def _S(): return sys.stdin.readline().rstrip()
def I(): return int(_S())
def LS(): return list(_S().split())
def LI(): return list(map(int,LS()))
if os.getenv("LOCAL"):
inputFile = basename_without_ext = os.path.splitext(os.path.basename(__file__))[0]... |
s894124979 | p02537 | u994521204 | 1601183313 | Python | PyPy3 (7.3.0) | py | Runtime Error | 99 | 73468 | 995 | import sys
input = sys.stdin.buffer.readline
n, k = map(int, input().split())
max_n = 300000 + 10
keta = max_n.bit_length()
num = 1 << (keta - 1)
SEG = [0] * (2 * num)
func = max
ele = 0
def update(idx, val):
idx += num
SEG[idx] = val
for i in reversed(range(1, num)):
SEG[i] = func(SEG[2 * i],... |
s640536341 | p02537 | u255898796 | 1601183074 | Python | PyPy3 (7.3.0) | py | Runtime Error | 670 | 122008 | 2219 | #####segfunc#####
def segfunc(x, y):
return max(x, y)
#################
#####ide_ele#####
ide_ele = 0
#################
class SegTree:
"""
init(init_val, ide_ele): 配列init_valで初期化 O(N)
update(k, x): k番目の値をxに更新 O(logN)
query(l, r): 区間[l, r)をsegfuncしたものを返す O(logN)
"""
def __init__(self, ini... |
s740070808 | p02537 | u994521204 | 1601182923 | Python | PyPy3 (7.3.0) | py | Runtime Error | 119 | 74448 | 999 | import sys
input = sys.stdin.buffer.readline
n, k = map(int, input().split())
max_n = 300000 + 10
SEG = [0] * (2 * max_n)
func = max
ele = 0
def update(idx, val):
idx += max_n
SEG[idx] = val
for i in reversed(range(1, max_n)):
SEG[i] = func(SEG[2 * i], SEG[2 * i + 1])
def query(left, right):... |
s614367162 | p02537 | u255898796 | 1601182883 | Python | PyPy3 (7.3.0) | py | Runtime Error | 603 | 122140 | 2219 | #####segfunc#####
def segfunc(x, y):
return max(x, y)
#################
#####ide_ele#####
ide_ele = 0
#################
class SegTree:
"""
init(init_val, ide_ele): 配列init_valで初期化 O(N)
update(k, x): k番目の値をxに更新 O(logN)
query(l, r): 区間[l, r)をsegfuncしたものを返す O(logN)
"""
def __init__(self, ini... |
s516639128 | p02537 | u571969099 | 1601182841 | Python | PyPy3 (7.3.0) | py | Runtime Error | 151 | 153772 | 3496 | from typing import Callable, TypeVar, List
T = TypeVar('T')
class SegTree:
def __init__(self, v: List[T], op: Callable[[T, T], T], e: Callable[[], T]) -> None:
self.__dict__["_n"] = len(v)
self.__dict__["log"] = (self.__dict__["_n"] - 1).bit_length()
self.__dict__["size"] = 1 << self.log
... |
s576339634 | p02537 | u255898796 | 1601182258 | Python | Python (3.8.2) | py | Runtime Error | 2207 | 34308 | 2212 | #####segfunc#####
def segfunc(x, y):
return max(x, y)
#################
#####ide_ele#####
ide_ele = 0
#################
class SegTree:
"""
init(init_val, ide_ele): 配列init_valで初期化 O(N)
update(k, x): k番目の値をxに更新 O(logN)
query(l, r): 区間[l, r)をsegfuncしたものを返す O(logN)
"""
def __init__(self, init_... |
s523315181 | p02537 | u255898796 | 1601181625 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 34196 | 2250 | #####segfunc#####
def segfunc(x, y):
return max(x, y)
#################
#####ide_ele#####
ide_ele = 0
#################
class SegTree:
"""
init(init_val, ide_ele): 配列init_valで初期化 O(N)
update(k, x): k番目の値をxに更新 O(logN)
query(l, r): 区間[l, r)をsegfuncしたものを返す O(logN)
"""
def __init__(self, init_... |
s893058866 | p02537 | u923270446 | 1601180285 | Python | PyPy3 (7.3.0) | py | Runtime Error | 106 | 84848 | 1388 | class SegmentTree:
def __init__(self, lis, ele, op):
self.len = len(lis)
self.n = 1 << ((self.len - 1).bit_length())
self.op = op
self.ele = ele
self.tree = self._build(lis)
def _build(self, lis):
res_tree = [self.ele] * (self.n - 1) + lis + [self.ele] * (self.n -... |
s390755516 | p02537 | u571969099 | 1601179366 | Python | PyPy3 (7.3.0) | py | Runtime Error | 188 | 80000 | 3183 | from typing import Callable, TypeVar, List
T = TypeVar('T')
class SegTree:
def __init__(self, v: List[T], op: Callable[[T, T], T], e: Callable[[], T]) -> None:
self._n = len(v)
self.log = (self._n - 1).bit_length()
self.size = 1 << self.log
self.d = [e() for _ in range(2 * self.si... |
s567827166 | p02537 | u551909378 | 1601178344 | Python | Python (3.8.2) | py | Runtime Error | 34 | 13212 | 991 | import math
N, K = map(int, input().split())
Amax = 300000
# seg_leaf : seg_tree の葉で [0:0) に当たるノードのインデックス
seg_leaf_0 = 2**int(math.log2(Amax+1))
# seg_tree : 1-indexed のセグ木
seg_tree = [0]*(seg_leaf_0 * 2)
def get_max(check_min, check_max, area_min, area_max, node_ind):
if area_max < check_min or check_max < area_... |
s486397808 | p02537 | u729133443 | 1601177857 | Python | Python (3.8.2) | py | Runtime Error | 34 | 9096 | 1541 | code = r"""
# distutils: language=c++
# distutils: include_dirs=/opt/atcoder-stl
from libcpp cimport bool
from libcpp.vector cimport vector
cdef extern from "<atcoder/segtree>" namespace "atcoder" nogil:
cdef cppclass segtree[S, OP, E]:
segtree(vector[S] v)
void set(int p, S x)
S get(int p)
... |
s020220953 | p02537 | u551909378 | 1601177830 | Python | Python (3.8.2) | py | Runtime Error | 39 | 13092 | 989 | import math
N, K = map(int, input().split())
Amax = 300000
# seg_leaf : seg_tree の葉で [0:0} に当たるノードのインデックス
seg_leaf_0 = 2**int(math.log2(Amax+1))
# seg_tree : 1-indexed のセグ木
seg_tree = [0]*(seg_leaf_0 * 2)
def get_max(check_min, check_max, area_min, area_max, node_ind):
if area_max < check_min or check_max < area_... |
s230294611 | p02537 | u852690916 | 1601177740 | Python | PyPy3 (7.3.0) | py | Runtime Error | 162 | 123684 | 2297 | # でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)
import sys
def main(N, K, A):
tree = SegmentTree(300_300)
for a in A:
p = tree.query(a - K, a + K + 1)
tree.modify(a, p + 1)
print(tree.query(0, 300_300))
class SegmentTree:
__slots__ = ('__n', '__d', '__f', '__e')
def __init__(self, n... |
s063055369 | p02537 | u111822487 | 1601177023 | Python | PyPy3 (7.3.0) | py | Runtime Error | 85 | 68704 | 484 | import numpy
l = input().split(' ')
N = int(l[0])
K = int(l[1])
A = []
for i in range(N):
A.append(int(input()))
dp = [-1]*(N+1)
dp[0] = 0
for i in range(N):
flg = False
n = numpy.amax(dp)
#print('a'+str(n))
for j in range(n,-1,-1):
arr = [k for k, x in enumerate(dp) if x == j]
#print(arr)
for ... |
s191383609 | p02537 | u111365362 | 1601175627 | Python | PyPy3 (7.3.0) | py | Runtime Error | 165 | 68676 | 848 | n,k = map(int,input().split())
scale = 21
scale = 3
seg = [0 for _ in range(2**scale)]
db = [2**i for i in range(scale)]
rdb = list(reversed(db))
#print(db)
#print(rdb)
#print(db)
for _ in range(n):
c = int(input())
l = max(c-k,0)
r = min(c+k+1,2**(scale-1))
maxi = 0
now = [[l,r]]
#print(now)
for i in ran... |
s331805527 | p02537 | u960080897 | 1601175295 | Python | PyPy3 (7.3.0) | py | Runtime Error | 494 | 96392 | 3277 | # Date [ 2020-09-26 21:43:42 ]
# Problem [ d.py ]
# Author Koki_tkg
import sys
def read_str(): return sys.stdin.readline().strip()
def read_int(): return int(sys.stdin.readline().strip())
def read_ints(): return map(int, sys.stdin.readline().strip().split())
def read_str_split(): return list(sys.stdin.readline().stri... |
s768973856 | p02537 | u993808866 | 1601175048 | Python | PyPy3 (7.3.0) | py | Runtime Error | 377 | 95392 | 256 | n, k = map(int, input().split())
a_list = [int(input()) for _ in range(n)]
dp = [1] * n
for i in range(n):
for j in range(max(0, i-N), i):
if abs(a_list[i] - a_list[j]) <= k:
dp[i] = max(dp[i], dp[j] + 1)
ans = max(dp)
print(ans) |
s048287650 | p02537 | u401686269 | 1601174964 | Python | PyPy3 (7.3.0) | py | Runtime Error | 733 | 123492 | 1415 | N,K=map(int,input().split())
class SegTree:
""" segment tree with point modification and range product. """
# # https://yukicoder.me/submissions/452850
def __init__(self, N, data_f = min, data_unit=1<<30):
self.N = N
self.data_f = data_f
self.data_unit = data_unit
self.data ... |
s114650609 | p02537 | u240444124 | 1601174952 | Python | PyPy3 (7.3.0) | py | Runtime Error | 166 | 79732 | 1612 | import sys
z=sys.stdin.readline
class SegmentTree:
def __init__(self, data, default=0, func=max):
self._default = default
self._func = func
self._len = len(data)
self._size = _size = 1 << (self._len - 1).bit_length()
self.data = [default] * (2 * _size)
self.data[_size... |
s792737377 | p02537 | u240444124 | 1601174918 | Python | PyPy3 (7.3.0) | py | Runtime Error | 121 | 79760 | 1616 | import sys
z=sys.stdin.readline
class SegmentTree:
def __init__(self, data, default=0, func=max):
self._default = default
self._func = func
self._len = len(data)
self._size = _size = 1 << (self._len - 1).bit_length()
self.data = [default] * (2 * _size)
self.data[_size... |
s838057762 | p02537 | u724687935 | 1601174887 | Python | PyPy3 (7.3.0) | py | Runtime Error | 1118 | 178148 | 2042 | 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
---------... |
s913408628 | p02537 | u240444124 | 1601174882 | Python | PyPy3 (7.3.0) | py | Runtime Error | 768 | 82232 | 1602 | import sys
z=sys.stdin.readline
class SegmentTree:
def __init__(self, data, default=0, func=max):
self._default = default
self._func = func
self._len = len(data)
self._size = _size = 1 << (self._len - 1).bit_length()
self.data = [default] * (2 * _size)
self.data[_size... |
s097017941 | p02537 | u050157681 | 1601174859 | Python | Python (3.8.2) | py | Runtime Error | 43 | 20652 | 832 | N,M = map(int, input().split())
notcalled=list(range(1,N+1))
nets=[]
for _ in range(M):
a,b=map(int, input().split())
if a in notcalled and b in notcalled:
nets.append([a,b])
del notcalled[notcalled.index(a)]
del notcalled[notcalled.index(b)]
elif a in notcalled:
for net in ... |
s418059533 | p02537 | u240444124 | 1601174840 | Python | PyPy3 (7.3.0) | py | Runtime Error | 100 | 85576 | 1641 | import sys,io,os
z=io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
class SegmentTree:
def __init__(self, data, default=0, func=max):
self._default = default
self._func = func
self._len = len(data)
self._size = _size = 1 << (self._len - 1).bit_length()
self.data = [default... |
s264810209 | p02537 | u129019798 | 1601174830 | Python | PyPy3 (7.3.0) | py | Runtime Error | 575 | 73568 | 488 | def main():
import sys
from bisect import bisect_left
N,K=list(map(int,sys.stdin.readline().split()))
A=[0]*N
for i in range(N):
A[i]=int(sys.stdin.readline())
dp=[0]*(N+1)
dp[0]=1
if abs(A[0]-A[1])<=K:
dp[1]=2
else:
dp[1]=1
for i in range(2,N):
... |
s770028671 | p02537 | u401686269 | 1601174586 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 31432 | 1417 | N,K=map(int,input().split())
class SegTree:
""" segment tree with point modification and range product. """
# # https://yukicoder.me/submissions/452850
def __init__(self, N, data_f = min, data_unit=1<<30):
self.N = N
self.data_f = data_f
self.data_unit = data_unit
self.data ... |
s935273810 | p02537 | u486094752 | 1601174471 | Python | Python (3.8.2) | py | Runtime Error | 373 | 20804 | 252 | N, K = map(int, input().split())
A = [int(input()) for i in range(N)]
ans = []
i = 0
while(i<=N-2):
a = A[i]
T = 1
while (j<=N-1):
if ( abs(a-A[j]) <= K ):
T += 1
a = A[j]
j += 1
ans.append(T)
i += 1
print(max(ans))
|
s316137349 | p02537 | u931769295 | 1601174404 | Python | Python (3.8.2) | py | Runtime Error | 117 | 27148 | 257 | import numpy as np
a=np.array(a)
n,k = map(int,input().split())
a = []
for i in range(n):
a.append(list(map(int,input().split())))
for i in range(n-1):
b = list(map(lambda x,y: x-y, a, a))
if abs(b) >= 3:
count += 1
print(count) |
s527679666 | p02537 | u316152477 | 1601174395 | Python | Python (3.8.2) | py | Runtime Error | 644 | 84664 | 329 | row = input().split()
N = int(row[0])
K = int(row[1])
An = []
for i in range(0, N):
An.append(input().split())
print(An)
for i in range(0, N-2):
Bn = abs(An[i] - An[i+1])
cnt = 0
Cn = []
for i in range (len(Bn)):
if Bn[i] <= K:
cnt += 1
Cn.append(cnt)
else:
cnt = 0
print(m... |
s773728286 | p02537 | u487767879 | 1601174393 | Python | Python (3.8.2) | py | Runtime Error | 129 | 53228 | 404 | import numpy as np
N, K = list(map(int, input().split()))
dp = np.ones((N+1, 300000+1)) * -1
for i in range(N):
A = int(input())
if dp[i, A] < 0:
dp[i, A] = 0
for j in np.where(dp[i,:] > -1)[0]:
if dp[i+1, j] < 0:
dp[i+1, j] = dp[i, j]
if (abs(A - j) <= K) and (dp[i+1, A... |
s427590232 | p02537 | u592826944 | 1601174391 | Python | PyPy3 (7.3.0) | py | Runtime Error | 146 | 87456 | 703 | import sys
try:sys.stdin,sys.stdout=open('in.txt','r'),open('out.txt','w')
except:pass
ii1=lambda:int(sys.stdin.readline().strip()) # for interger
is1=lambda:sys.stdin.readline().strip() # for str
iia=lambda:list(map(int,sys.stdin.readline().strip().split())) # for List[int]
isa=lambda:sys.stdin.readline().strip().spli... |
s185024598 | p02537 | u102655885 | 1601174386 | Python | Python (3.8.2) | py | Runtime Error | 416 | 21724 | 902 | n, k = map(lambda x: int(x), input().split())
list_a = []
for _ in range(n):
list_a.append(int(input()))
memo = dict()
def subilst_max_length(current_value, i):
if (current_value, i) in memo.keys():
return memo[(current_value, i)]
if i == n-1:
if (current_value is None) or (abs(... |
s565071341 | p02537 | u516079739 | 1601174375 | Python | Python (3.8.2) | py | Runtime Error | 73 | 9412 | 214 | n,q = input().split(' ')
n = int(n)
q=int(q)
s=''
a =[]
for i in range(n):
s+='1'
c=''
for _ in range(q):
a,b,c=input().split(' ')
a=int(a)
b=int(b)
for i in range(a,b):
s+=c;
print(s) |
s700410354 | p02537 | u879921371 | 1601174340 | Python | Python (3.8.2) | py | Runtime Error | 34 | 8996 | 646 | n,k=map(int,input().split())
a=[None]*n
m=0
lian=0
a0=int(input())
a[0]=a0
for i in range(1,n):
a1=int(input())
a[i]=a1
if a1-a0 >k:
pass
elif a0-a1>k:
pass
else:
lian+=1
if lian>m:
m=lian
a0=int(a1)
m1=0
lian=0
a0=a[n-1]
for i in range(2,n+1):
a1=a[n-i]
if a1-a0 >k:
pass
e... |
s897048354 | p02537 | u487767879 | 1601174336 | Python | Python (3.8.2) | py | Runtime Error | 163 | 52972 | 402 | import numpy as np
N, K = list(map(int, input().split()))
dp = np.ones((N+1, 300000)) * -1
for i in range(N):
A = int(input())
if dp[i, A] < 0:
dp[i, A] = 0
for j in np.where(dp[i,:] > -1)[0]:
if dp[i+1, j] < 0:
dp[i+1, j] = dp[i, j]
if (abs(A - j) <= K) and (dp[i+1, A] ... |
s950872008 | p02537 | u216928054 | 1601174312 | Python | PyPy3 (7.3.0) | py | Runtime Error | 2210 | 170776 | 4059 | #!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**6)
INF = 10 ** 9 + 1 # sys.maxsize # float("inf")
MOD = 10 ** 9 + 7
def debug(*x):
print(*x, file=sys.stderr)
def solve_0_WA(N, K, AS):
candidates = [[0]]
for i in range(1, N):
A = AS[i]
new_candidates = []
for c in can... |
s675156585 | p02537 | u235376569 | 1601174262 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 32876 | 299 | n,k=map(int,input().split())
l=[]
for i in range(n):
a=int(input())
l.append(a)
sa=[]
ss=[]
for i in range(n-1):
sa.append(l[i]-l[i+1])
for i in range(len(sa)-1):
if len(sa)<=i:
break
if k<abs(sa[i]) and abs(sa[i]+sa[i+1])<=k:
sa[i]=l[i]-l[i+2]
sa.pop(i+1)
print(len(sa)+1) |
s369347011 | p02537 | u738257898 | 1601174225 | Python | Python (3.8.2) | py | Runtime Error | 373 | 20968 | 667 | import sys
sys.setrecursionlimit(1000000)
def recursion(arr, length, idx, value, criteria, counta):
if idx >= length:
return counta
if abs(arr[idx] - value) <= criteria:
result_skip = recursion(arr, length, idx + 1, value, criteria, counta)
result_process = recursion(arr, length, idx +... |
s640713762 | p02537 | u363421241 | 1601174220 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 29676 | 414 | def main():
n, k = map(int, input().split())
a = [0]
for _ in range(n):
a.append(int(input()))
table = [0]*(n+1)
dp = [0]*(n+1)
for i in range(1, n+1):
down = a[i]-k
up = a[i]+k
if down < 0:
down = 0
if up > n:
up = n
... |
s088910178 | p02537 | u754869388 | 1601174183 | Python | Python (3.8.2) | py | Runtime Error | 394 | 21732 | 809 | #input
n, k = map(int,input().split())
a = [int(input()) for i in range(n)]
def input_2(n,k):
n, k = map(int,input().split())
a = [randint(1, k) for i in range(n)]
return n,k,a
def connect(i,d,p,q):
if i+d >= n:
if p > q:
q = p
#print("bbbb {} {}".format(p,q))
retu... |
s133270140 | p02537 | u364774090 | 1601174139 | Python | Python (3.8.2) | py | Runtime Error | 494 | 20764 | 217 | N, K = [int(i) for i in input().split()]
A = [0] * N
for i in range(N):
A[i] = int(input())
ans = 0
i, j = 0, 1
while i < N - 2:
if abs(A[i] - A[j]) <= K:
ans += 1
i = j
j += 1
if ans > 0:
ans += 1
print(ans)
|
s124050338 | p02537 | u924241064 | 1601174130 | Python | PyPy3 (7.3.0) | py | Runtime Error | 523 | 129664 | 268 | N, K = map(int, input().split())
list = [int(input()) for _ in range(N)]
print(list)
new_list = []
new_list.append(list[0])
for i in range(N):
did = new_list[-1] - list[i]
if did <= K:
new_list.append(list[i + 1])
print(len(new_list))
|
s762303311 | p02537 | u738257898 | 1601174084 | Python | Python (3.8.2) | py | Runtime Error | 585 | 51800 | 1063 | def solve(city_arr, road_arr):
# points = [road_arr[0][0],road_arr[0][1]]
starts = [road[0] for road in road_arr]
ends = [road[1] for road in road_arr]
points = starts
points.extend(ends)
set_cities = set(points)
used = [False for road in road_arr]
is_end = True
counta = 0
idx = ... |
s403889499 | p02537 | u919235786 | 1601174058 | Python | Python (3.8.2) | py | Runtime Error | 430 | 21728 | 275 | n,k=map(int,input().split())
a=[]
for i in range(n):
ai=int(input())
a.append(ai)
def rec(x):
ans=1
for i in range(x+1,n):
if abs(a[i]-a[x])<=k:
ans=max(rec(i)+1,ans)
return ans
b=0
for i in range(n):
b=max(b,rec(i))
print(b) |
s937442130 | p02537 | u289288647 | 1601174048 | Python | PyPy3 (7.3.0) | py | Runtime Error | 415 | 114360 | 714 | def FlatSub():
n, k = map(int, input().split())
a = [int(input()) for _ in range(n)]
diff = []
ans, count = 0, 0
for i in range(n-1):
num = a[i+1]-a[i]
diff.append(num)
if abs(num) <= k:
count += 1
else:
ans = max(ans, count)
count... |
s356065802 | p02537 | u260370057 | 1601174043 | Python | Python (3.8.2) | py | Runtime Error | 412 | 21544 | 247 | def flat(a,k):
if len(a) == 1:
return a
ab = a.pop(-1)
b = flat(a,k)
if abs(b[-1] - ab) <= k:
b.append(ab)
return b
n,k = map(int,input().split())
a = []
for i in range(n):
ain = int(input())
a.append(ain)
b = flat(a,k)
print(len(b)) |
s050100457 | p02537 | u642012866 | 1601174001 | Python | PyPy3 (7.3.0) | py | Runtime Error | 749 | 80368 | 1147 | N, K = map(int, input().split())
def init_max(init_max_val):
#set_val
for i in range(N):
seg_max[i+num_max-1]=init_max_val[i]
#built
for i in range(num_max-2,-1,-1) :
seg_max[i]=max(seg_max[2*i+1],seg_max[2*i+2])
def update_max(k,x):
k += num_max-1
seg_max[k] = x
w... |
s247284584 | p02537 | u363421241 | 1601173911 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 29864 | 329 | n, k = map(int, input().split())
a = [0]
for _ in range(n):
a.append(int(input()))
a.append(0)
table = [0]*(n+1)
dp = [0]*(n+1)
for i in range(1, n+1):
down = a[i]-k
up = a[i]+k
if down < 1:
down = 1
if up > n:
up = n
dp[i] = max(table[down:up+1])+1
table[a[i]] = dp[i]
prin... |
s953374878 | p02537 | u367701763 | 1601173844 | Python | PyPy3 (7.3.0) | py | Runtime Error | 1371 | 95684 | 8732 | class LazySegmentTree():
def __init__(self, n, f, g, h, ef, eh):
"""
:param n: 配列の要素数
:param f: 取得半群の元同士の積を定義
:param g: 更新半群の元 xh が配列上の実際の値にどのように作用するかを定義
:param h: 更新半群の元同士の積を定義 (更新半群の元を xh と表記)
:param x: 配列の各要素の値。treeの葉以外は xf(x1,x2,...)
"""
self.n = ... |
s727786185 | p02537 | u069125420 | 1601173836 | Python | Python (3.8.2) | py | Runtime Error | 2216 | 408480 | 584 | import sys
sys.setrecursionlimit(100000)
N, K = map(int, input().split())
A = [int(input()) for i in range(N)]
memo = {}
def solve(n, v):
if (n, v) in memo:
return memo[(n, v)]
if n == N - 1:
if abs(v - A[n]) <= K:
return 1
else:
return 0
else:
if ... |
s257808073 | p02537 | u661764795 | 1601173786 | Python | Python (3.8.2) | py | Runtime Error | 675 | 49752 | 456 | N, Q = map(int, input().split())
LRD = [list(map(int, input().split())) for _ in range(Q)]
mod = 998244353
l = []
t = ''
for i in range(20000):
t += '1'
for i in range(1, 10):
l.append(str(int(t) * i))
S = ''
for i in range(N):
S += '1'
for i in range(Q):
t = l[LRD[i][2] - 1]
while len(t) < LRD[... |
s914366597 | p02537 | u661764795 | 1601173775 | Python | PyPy3 (7.3.0) | py | Runtime Error | 2211 | 251280 | 456 | N, Q = map(int, input().split())
LRD = [list(map(int, input().split())) for _ in range(Q)]
mod = 998244353
l = []
t = ''
for i in range(20000):
t += '1'
for i in range(1, 10):
l.append(str(int(t) * i))
S = ''
for i in range(N):
S += '1'
for i in range(Q):
t = l[LRD[i][2] - 1]
while len(t) < LRD[... |
s048909387 | p02537 | u069125420 | 1601173768 | Python | Python (3.8.2) | py | Runtime Error | 396 | 21732 | 544 | N, K = map(int, input().split())
A = [int(input()) for i in range(N)]
memo = {}
def solve(n, v):
if (n, v) in memo:
return memo[(n, v)]
if n == N - 1:
if abs(v - A[n]) <= K:
return 1
else:
return 0
else:
if abs(v - A[n]) <= K:
res = ma... |
s687308024 | p02537 | u666550725 | 1601173618 | Python | PyPy3 (7.3.0) | py | Runtime Error | 89 | 68820 | 189 | N, K = map(int, input().split())
M = 20
P = [0 for k in range(M+1)]
for i in range(N):
a = int(input())
c = max(P[max(a - K, 0):min(a+K+1, M+1)]) + 1
P[a] = max(P[a], c)
print(max(P)) |
s978664224 | p02537 | u163393400 | 1601173600 | Python | Python (3.8.2) | py | Runtime Error | 594 | 23164 | 433 | N,K=map(int,input().split())
l=[]
for i in range(N):
l.append(int(input()))
ll=[]
def s(n,l,ll,K):
for i in range(n+1,len(l)):
if abs(l[n]-l[i]) <= K:
ll.append(l[n])
return(i)
else:
continue
return
i=0
while True:
j=s(i,l,ll,K)
i=j
... |
s748118976 | p02537 | u506910932 | 1601173531 | Python | Python (3.8.2) | py | Runtime Error | 528 | 23360 | 318 | n, k = map(int, input().split())
N = []
for i in range(n):
N.append(int(input()))
# 隣同士がいくつ離れているかをカウント
dist = [0 for _ in range(n + 3)]
for i in range(1, n):
dist[abs(N[i] - N[i - 1])] += 1
ans = 0
for i in range(k + 1):
ans += dist[i]
# print(dist)
print(ans + 1)
|
s790641556 | p02537 | u441575327 | 1601173529 | Python | PyPy3 (7.3.0) | py | Runtime Error | 359 | 95008 | 512 | from collections import deque
N,K = list(map(int,input().split()))
A = [int(input()) for i in range(N)]
if N == 1:
print(1)
exit()
lst = [-1]*(N+1)
queue = deque()
queue.append((A[0],1,1))
while queue:
# print(queue)
r,size,i = queue.popleft()
if i == N:
continue
if lst[r] <= size:
... |
s089436793 | p02537 | u476225888 | 1601173479 | Python | PyPy3 (7.3.0) | py | Runtime Error | 1132 | 113760 | 3739 | import sys, math
import io, os
#data = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
from bisect import bisect_left as bl, bisect_right as br, insort
from heapq import heapify, heappush, heappop
from collections import defaultdict as dd, deque, Counter
# from itertools import permutations,combinations
def data():... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.