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
s361975730
p02537
u441575327
1601173418
Python
PyPy3 (7.3.0)
py
Runtime Error
375
94840
511
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)) ans = 0 while queue: # print(queue) r,size,i = queue.popleft() if i == N: ans = max(ans,size) ...
s690566206
p02537
u626891113
1601173414
Python
PyPy3 (7.3.0)
py
Runtime Error
630
95896
272
n, k = map(int, input().split()) l = [] for i in range(n): l.append(int(input())) root = [1]*n for i in range(n)[-2::-1]: num = 0 for j in l[i + 1: i + 100]: if abs(i - j) <= k: num = max(num, root[j]) root[i] += num print(max(root))
s761553362
p02537
u990726146
1601173384
Python
PyPy3 (7.3.0)
py
Runtime Error
1473
160280
2516
N, K = map(int, input().split()) A = [[-1] for i in range(300010)] d = [0] * N for i in range(N): d[i] = int(input()) A[d[i]].append(i) c = [[0] * 2 for i in range(N)] def segfunc(x, y): return max(x, y) ################# #####ide_ele##### ide_ele = -float("INF") ################# a = [0] * 300010 for i...
s042751451
p02537
u544587633
1601173379
Python
Python (3.8.2)
py
Runtime Error
384
41056
1468
#!/usr/bin/env python3 import sys import numpy as np def func(i,j,k,K, A): if abs(A[i] - A[j]) <= K: return i, j elif abs(A[i] - A[k]) <= K: return i, k elif abs(A[j] - A[k]) <= K: return j, k else: return 0,0 def solve(N: int, K: int, A: "List[int]"): if N == 1...
s560789947
p02537
u919235786
1601173367
Python
Python (3.8.2)
py
Runtime Error
421
21628
242
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 print(rec(0))
s404488739
p02537
u642012866
1601173327
Python
PyPy3 (7.3.0)
py
Runtime Error
742
80880
691
N, K = map(int, input().split()) # N: 処理する区間の長さ N0 = 2**(N-1).bit_length() INF = 0 data = [INF]*(2*N0) # a_k の値を x に更新 def update(k, x): k += N0-1 data[k] = x while k >= 0: k = (k - 1) // 2 data[k] = max(data[2*k+1], data[2*k+2]) # 区間[l, r)の最小値 def query(l, r): L = l + N0; R = r + N0 ...
s284358878
p02537
u441575327
1601173312
Python
PyPy3 (7.3.0)
py
Runtime Error
375
94936
489
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)) ans = 0 while queue: # print(queue) r,size,i = queue.popleft() if i == N: ans = max(ans,size) ...
s596082207
p02537
u354862173
1601173310
Python
PyPy3 (7.3.0)
py
Runtime Error
98
75484
1124
import sys from math import ceil as C, floor as F, sqrt, gcd as G from collections import defaultdict as D, Counter as CNT from functools import reduce as R import heapq as HQ class Heap: def __init__(self, data, reverse=False): self.reverse = -1 if reverse else 1 self.data = [self.reverse * d for d in data]...
s064467907
p02537
u745514010
1601173277
Python
PyPy3 (7.3.0)
py
Runtime Error
2209
118208
1888
import sys input = sys.stdin.readline def main(): n, k = map(int, input().split()) alst = [int(input()) for _ in range(n)] N = 300010 ll = - 10 ** 10 LV = (N-1).bit_length() N0 = 2**LV data = [0]*(2*N0) lazy = [ll]*(2*N0) def gindex(l, r): L = (l + N0) >> 1; R ...
s173824691
p02537
u441575327
1601173243
Python
PyPy3 (7.3.0)
py
Runtime Error
379
99420
489
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,2)) ans = 0 while queue: # print(queue) r,size,i = queue.popleft() if i == N: ans = max(ans,size) ...
s214629801
p02537
u626891113
1601173222
Python
PyPy3 (7.3.0)
py
Runtime Error
2208
96920
303
n, k = map(int, input().split()) l = [] for i in range(n): l.append(int(input())) root = [1]*n for i in range(n)[-2::-1]: num = 0 for j in l[i + 1:]: if abs(i - j) <= k: num = max(num, root[j]) root[i] += num if i < n - 1000: del l[-1] print(max(root))
s839628049
p02537
u589969467
1601173177
Python
PyPy3 (7.3.0)
py
Runtime Error
395
96752
401
def dfs(start): global myList if start==n: return if len(myList) == 0: myList.append(a[start]) dfs(start+1) else: if abs(myList[-1]-a[start])<=k: myList.append(a[start]) dfs(start+1) n,k = map(int,input().split()) a = [] for i in range(n): a.append(int(input())) #print(a) ans = 0 ...
s542201598
p02537
u745514010
1601173050
Python
PyPy3 (7.3.0)
py
Runtime Error
1977
117948
1817
import sys input = sys.stdin.readline def main(): n, k = map(int, input().split()) alst = [int(input()) for _ in range(n)] N = max(alst) + 1 LV = (N-1).bit_length() N0 = 2**LV data = [0]*(2*N0) lazy = [0]*(2*N0) def gindex(l, r): L = (l + N0) >> 1; R = (r + N0) >>...
s869729876
p02537
u642012866
1601173021
Python
PyPy3 (7.3.0)
py
Runtime Error
675
80944
2111
import sys sys.setrecursionlimit(10**8) N, K = map(int, input().split()) #####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(...
s896275578
p02537
u970197315
1601172949
Python
PyPy3 (7.3.0)
py
Runtime Error
403
114344
564
n, k = map(int, input().split()) a = [int(input()) for i in range(n)] b = [] # print(a) l = 0 r = 1 while l < n: if l == r and r < n: r += 1 if l == n-1: if abs(a[l]-b[-1]) <= k: b.append(a[l]) break if len(b) == 0: if abs(a[r]-a[l]) <= k: ...
s914462503
p02537
u876754484
1601172903
Python
Python (3.8.2)
py
Runtime Error
2206
20856
464
n,k = [int(x) for x in input().split()] nums = [] absnums = [] for i in range(n): nums.append(int(input())) #print(nums) for i in range(len(nums)-1): if i == len(nums)-1: break if abs(nums[i]-nums[i+1]) > k: while(abs(nums[i] - nums[i+1]) > k): del n...
s218574149
p02537
u240444124
1601172833
Python
Python (3.8.2)
py
Runtime Error
2206
22036
1596
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...
s375393886
p02537
u376752722
1601172818
Python
Python (3.8.2)
py
Runtime Error
1696
138648
224
n, k = map(int, input().split()) a = [] index = 0 for i in range(n): tmp = int(input()) if i > 0: if abs(a[index-1] - tmp) > k: continue index += 1 a.append(tmp) print(a) print(len(a))
s402816734
p02537
u887733878
1601172813
Python
PyPy3 (7.3.0)
py
Runtime Error
797
143764
1937
N,K=map(int,input().split()) A=[] for i in range(N): a=int(input()) A.append(a) #####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)...
s651032974
p02537
u876754484
1601172751
Python
Python (3.8.2)
py
Runtime Error
2206
32408
498
n,k = [int(x) for x in input().split()] nums = [] absnums = [] for i in range(n): nums.append(int(input())) #print(nums) for i in range(len(nums)-1): if i == len(nums)-1: break if abs(nums[i]-nums[i+1]) <= k: absnums.append(abs(nums[i]-nums[i+1])) else: ...
s907964216
p02537
u505830998
1601172743
Python
PyPy3 (7.3.0)
py
Runtime Error
711
103808
1823
import sys input_methods=['clipboard','file','key'] using_method=1 input_method=input_methods[using_method] tin=lambda : map(int, input().split()) lin=lambda : list(tin()) mod=1000000007 #+++++ #+++++ isTest=False def pa(v): if isTest: print(v) def input_clipboard(): import clipboard input_text=clipboard.g...
s310220440
p02537
u952491523
1601172647
Python
PyPy3 (7.3.0)
py
Runtime Error
715
109988
2105
#####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, i...
s701478969
p02537
u642012866
1601172629
Python
Python (3.8.2)
py
Runtime Error
2206
20352
2070
N, K = map(int, input().split()) #####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) ...
s905588407
p02537
u370721525
1601172617
Python
PyPy3 (7.3.0)
py
Runtime Error
398
93120
254
N, K = map(int, input().split()) l = [] for i in range(N): l.append(int(input())) cnts = [0] * 20 for i in range(N-1): tmp = 0 for j in range(max(l[i]-3, 0), min(l[i]+4, 300000)): tmp = max(tmp, cnts[j]) cnts[l[i]] = tmp+1 print(max(cnts))
s927922554
p02537
u102655885
1601172562
Python
Python (3.8.2)
py
Runtime Error
424
21816
952
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): print(current_value, i) if (current_value, i) in memo.keys(): print('here') return memo[(current_value, i)] if i >...
s651500872
p02537
u887733878
1601172524
Python
Python (3.8.2)
py
Runtime Error
2206
34328
2170
N,K=map(int,input().split()) A=[] for i in range(N): a=int(input()) A.append(a) #####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)...
s513131630
p02537
u887733878
1601172499
Python
PyPy3 (7.3.0)
py
Runtime Error
789
142672
2170
N,K=map(int,input().split()) A=[] for i in range(N): a=int(input()) A.append(a) #####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)...
s540189058
p02537
u366886346
1601172494
Python
PyPy3 (7.3.0)
py
Runtime Error
601
80420
1233
N,K=map(int,input().split()) 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() self.tree = [ide_ele] * 2 * self.num for i in range(n): self.tr...
s993058306
p02537
u919235786
1601172494
Python
Python (3.8.2)
py
Runtime Error
424
21464
312
n,k=map(int,input().split()) a=[] for i in range(n): ai=int(input()) a.append(ai) def rec(x): ans=1 if x==n-1: return 1 else: for i in range(x+1,n): if abs(a[i]-a[x])<=k: ans=max(rec(i)+1,ans) return ans print(rec(0))
s375320795
p02537
u952491523
1601172442
Python
PyPy3 (7.3.0)
py
Runtime Error
672
110552
2103
#####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, i...
s592521090
p02537
u366886346
1601172427
Python
Python (3.8.2)
py
Runtime Error
2206
20444
1303
N,K=map(int,input().split()) 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() self.tree = [ide_ele] * 2 * self.num # 配列の値を葉にセット for i in range(n)...
s671475299
p02537
u910358825
1601172397
Python
Python (3.8.2)
py
Runtime Error
2206
20940
346
n,k=map(int, input().split()) a=[int(input()) for i in range(n)] i=0 maxs=1 #lis=[] for i in range(n-1): cnt=1 j=1 while i<=n-2: if abs(a[i+j]-a[i])<=k: #lis.append(a[i+j]) #print(lis) cnt+=1 i+=j j=1 else: j+=1 maxs...
s447156910
p02537
u919235786
1601172379
Python
Python (3.8.2)
py
Runtime Error
408
21512
316
n,k=map(int,input().split()) a=[] for i in range(n): ai=int(input()) a.append(ai) def rec(x): ans=1 if x==n-1: return 1 else: for i in range(x+1,n): if abs(a[i]-a[x])<=k: ans=max(rec(i)+1,ans) return ans print(rec(0))
s424813475
p02537
u240444124
1601172254
Python
Python (3.8.2)
py
Runtime Error
2206
23912
1654
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...
s965387564
p02537
u366886346
1601172239
Python
Python (3.8.2)
py
Runtime Error
2206
20356
1974
N,K=map(int,input().split()) 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, ide_ele): """ init_val: 配列の初期値 segfunc: 区間にしたい操作 id...
s760968740
p02537
u631521893
1601172177
Python
Python (3.8.2)
py
Runtime Error
25
8980
258
n, k = map(int, input().split()) count = 0 for i in range(n): a = int(input()) if i == 0: prev = a if abs(a - prev) <= k: if count == 0: if i != 0: count += 2 prev = a else: count += 1 prev = a print(count)
s634318566
p02537
u738257898
1601172172
Python
Python (3.8.2)
py
Runtime Error
388
21772
664
def recursion(arr, length, idx, value, criteria, counta): if idx >= length: return counta if arr[idx] - value <= criteria: result_skip = recursion(arr, length, idx + 1, value, criteria, counta) result_process = recursion(arr, length, idx + 1, arr[idx], criteria, counta+1) if res...
s542261578
p02537
u888092736
1601172151
Python
PyPy3 (7.3.0)
py
Runtime Error
535
122100
1036
class SegmentTree: def __init__(self, n, op, e): self.n = 1 << (n - 1).bit_length() self.op = op self.e = e self.data = [e] * (2 * self.n) def update(self, k, v): k += self.n self.data[k] = v while k > 0: k >>= 1 self.data[k] = sel...
s002878213
p02537
u598296382
1601172099
Python
PyPy3 (7.3.0)
py
Runtime Error
732
92820
2148
# セグ木 # 使う操作 #####segfunc##### def segfunc1(x, y): return max(x, y) ################# #####ide_ele##### ide_ele1 = -float('inf') ################# 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) """ ...
s782148844
p02537
u616382321
1601172052
Python
Python (3.8.2)
py
Runtime Error
1607
22968
578
N, K = map(int, input().split()) A = [int(input()) for _ in range(N)] cnt = 0 for i in range(N): if abs(A[i] - A[i+1]) <= K: break cnt += 1 dq = [A[cnt]] i = cnt + 1 while i < N: if abs(A[i] - A[i-1]) <= K and abs(A[i] - dq[-1]) <= K: dq.append(A[i]) else: for s in range(1,min(...
s868643240
p02537
u240444124
1601172049
Python
Python (3.8.2)
py
Runtime Error
211
23912
1640
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...
s598957914
p02537
u919235786
1601172037
Python
Python (3.8.2)
py
Runtime Error
414
21648
316
n,k=map(int,input().split()) a=[] for i in range(n): ai=int(input()) a.append(ai) def rec(x): ans=1 if x==n-1: return 1 else: for i in range(x+1,n): if abs(a[i]-a[x])<=k: ans=max(rec(i)+1,ans) return ans print(rec(0))
s885952444
p02537
u347640436
1601172028
Python
Python (3.8.2)
py
Runtime Error
28
9004
2317
package main import ( "bufio" "fmt" "os" "strconv" ) func min(x, y int) int { if x < y { return x } return y } func max(x, y int) int { if x > y { return x } return y } type segmentTree struct { offset int data []int op func(x, y int) int e int } func newSegmentTree(n int, op func(x, y...
s313521196
p02537
u344030307
1601172020
Python
Python (3.8.2)
py
Runtime Error
2206
11392
235
n,k = map(int, input().split()) b = [0] * (n+1) ans = 0 for i in range(n): a = int(input()) m = b[a] + 1 s = max(1, a-k) u = min(n+1, a+k+1) for j in range(s, u): b[j] = max(b[j],m) if m > ans: ans = m print(ans)
s709611947
p02537
u334712262
1601171995
Python
PyPy3 (7.3.0)
py
Runtime Error
1191
126260
4286
# -*- coding: utf-8 -*- import bisect import heapq import math import random from collections import Counter, defaultdict, deque from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal from fractions import Fraction from functools import lru_cache, reduce from itertools import combinations, combinations_with_replacem...
s663511416
p02537
u325282913
1601171929
Python
PyPy3 (7.3.0)
py
Runtime Error
2240
1208804
2803
import sys sys.setrecursionlimit(10**8) class Scc: def __init__(self,n): self.n = n self.edges = [] def add_edge(self,fr,to): assert 0 <= fr < self.n assert 0 <= to < self.n self.edges.append((fr, to)) def scc(self): csr_start = [0] * (self.n + 1) cs...
s204327720
p02537
u738257898
1601171920
Python
Python (3.8.2)
py
Runtime Error
394
21772
716
def recursion(arr, idx, value, criteria, counta): if idx >= len(arr): return counta # print(idx, value, arr[idx], 'criteria', criteria) if arr[idx] - value <= criteria: result_skip = recursion(arr, idx + 1, value, criteria, counta) result_process = recursion(arr, idx + 1, arr[idx],...
s304455501
p02537
u226849101
1601171919
Python
Python (3.8.2)
py
Runtime Error
441
24004
424
N, K = map(int, input().split()) A = [-1 for i in range(N)] dp = [-1 for i in range(N)] for i in range(N): A[i] = int(input()) def solve(p,a): global N,K,A,dp ans = 0 if dp[p] != -1: ans = dp[p] elif p==N-1: ans = 0 elif abs(A[p]-a)>K: ans = solve(p+1,a) else: ...
s751662296
p02537
u201928947
1601171890
Python
PyPy3 (7.3.0)
py
Runtime Error
813
78108
1102
class SegTree: X_unit = 0 X_f = max def __init__(self, N): self.N = N self.X = [0] * (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], self.X[i ...
s816870079
p02537
u364774090
1601171888
Python
Python (3.8.2)
py
Runtime Error
500
20856
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 - 1: if abs(A[i] - A[j]) <= K: ans += 1 i = j j += 1 if ans > 0: ans += 1 print(ans)
s600136166
p02537
u321605735
1601171858
Python
Python (3.8.2)
py
Runtime Error
505
77792
231
r=input().split() N=int(r[0]) Q=int(r[1]) data="1"*N d=[input().split() for i in range(Q)] for i in range(Q): data=data[0:int(d[i][0])-1]+d[i][2]*(int(d[i][1])-int(d[i][0])+1)+data[int(d[i][1]):N] print(int(data)%998244353)
s858070404
p02537
u528181687
1601171855
Python
Python (3.8.2)
py
Runtime Error
2206
15696
211
def main(): n, k = map(int, input().split()) cnt = [0] * (n+1) for _ in range(n): a = int(input()) m = max(cnt[max(a-k,0):min(a+k,n)+1]) cnt[a] = m+1 print(cnt[a]) main()
s225190432
p02537
u376752722
1601171839
Python
Python (3.8.2)
py
Runtime Error
27
8956
137
n, k = map(int, input()) a = [] for i in range(n): if(i >= 1 and Math.abs(a[i-1] < a[i]) < k): a.push(int(input())) print(a.length())
s106211785
p02537
u598296382
1601171833
Python
PyPy3 (7.3.0)
py
Runtime Error
778
92804
2144
# セグ木 # 使う操作 #####segfunc##### def segfunc1(x, y): return max(x, y) ################# #####ide_ele##### ide_ele1 = -float('inf') ################# 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) """ ...
s876186871
p02537
u741579801
1601171829
Python
Python (3.8.2)
py
Runtime Error
818
23372
472
N, K = [int(n) for n in input().split(" ")] A = [] for _ in range(N): A.append(int(input())) D = [-1 for _ in range(300001)] DD = [] ANS = -1 for n in range(N): maxd = -1 for s in range(A[n] - K, A[n] + K + 1): if s < 0 or s > 300001: continue d = D[s] + 1 if maxd <= ...
s753735163
p02537
u397496203
1601171806
Python
PyPy3 (7.3.0)
py
Runtime Error
489
76276
1425
import sys # sys.setrecursionlimit(100000) def input(): return sys.stdin.readline().strip() def input_int(): return int(input()) def input_int_list(): return [int(i) for i in input().split()] class SegTree: X_unit = 0 X_f = max def __init__(self, N): self.N = N self.X =...
s157967957
p02537
u415718506
1601171770
Python
Python (3.8.2)
py
Runtime Error
511
54424
5944
import types _atcoder_code = """ # Python port of AtCoder Library. __version__ = '0.0.1' """ atcoder = types.ModuleType('atcoder') exec(_atcoder_code, atcoder.__dict__) _atcoder__bit_code = """ def _ceil_pow2(n: int) -> int: x = 0 while (1 << x) < n: x += 1 return x def _bsf(n: int) -> int: ...
s360436837
p02537
u415718506
1601171724
Python
Python (3.8.2)
py
Runtime Error
37
10616
1820
import sys import heapq, functools, collections import math, random from collections import Counter, defaultdict # from atcoder.fenwicktree import FenwickTree # available on Google, not available on Codeforces # import numpy as np # import scipy import typing from atcoder.segtree import SegTree LARGE = 3*10**5 ...
s117291303
p02537
u910358825
1601171665
Python
Python (3.8.2)
py
Runtime Error
2206
21024
338
n,k=map(int, input().split()) a=[int(input()) for i in range(n)] i,j=0,1 maxs=0 lis=[] for i in range(n): cnt=1 while i<n-1: if abs(a[i+j]-a[i])<=k: #lis.append(a[i+j]) #print(lis) cnt+=1 i+=j j=1 else: j+=1 maxs=max(max...
s812660771
p02537
u201928947
1601171642
Python
PyPy3 (7.3.0)
py
Runtime Error
102
73384
1102
class SegTree: X_unit = 0 X_f = max def __init__(self, N): self.N = N self.X = [0] * (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], self.X[i ...
s514763790
p02537
u860829879
1601171634
Python
PyPy3 (7.3.0)
py
Runtime Error
671
102420
1164
tmpn,k=map(int,input().split()) a=[int(input()) for _ in range(tmpn)] n=3*10**5+2 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(...
s807699515
p02537
u745514010
1601171613
Python
PyPy3 (7.3.0)
py
Runtime Error
2209
136616
2063
import sys input = sys.stdin.readline def main(): n, k = map(int, input().split()) alst = [int(input()) for _ in range(n)] N = max(alst) + 1 INF = 0 LV = (N-1).bit_length() N0 = 2**LV data = [INF]*(2*N0) lazy = [None]*(2*N0) def gindex(l, r): L = (l + N0) >> 1...
s383141326
p02537
u102655885
1601171563
Python
Python (3.8.2)
py
Runtime Error
434
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(...
s247031667
p02537
u486094752
1601171555
Python
Python (3.8.2)
py
Runtime Error
28
9072
172
N, K = map(int, input().split()) A = [int(input()) for i in range(5)] ans = 1 i = 1 while( i <= N-2 ): if ( abs(A[i]-A[i+1]) <= K ): ans += 1 i += 1 print(ans)
s912422081
p02537
u152417130
1601171519
Python
PyPy3 (7.3.0)
py
Runtime Error
110
70644
3249
class LazySegmentTree: def __init__(self, data, default=0, func=max): """initialize the lazy segment tree with data""" self._default = default self._func = func self._len = len(data) self._size = _size = 1 << (self._len - 1).bit_length() self._lazy = [0] * (2 * _size...
s803498600
p02537
u843135954
1601171507
Python
PyPy3 (7.3.0)
py
Runtime Error
462
78688
931
import sys stdin = sys.stdin sys.setrecursionlimit(10**7) ni = lambda: int(ns()) na = lambda: list(map(int, stdin.readline().split())) nn = lambda: list(stdin.readline().split()) ns = lambda: stdin.readline().rstrip() n,k = na() N = n # N: 処理する区間の長さ N0 = 2**(N-1).bit_length() INF = 2**31-1 data = [0]*(2*N0) # a_k の値...
s935791302
p02537
u054514819
1601171444
Python
PyPy3 (7.3.0)
py
Runtime Error
465
78752
1587
import sys def input(): return sys.stdin.readline().strip() def mapint(): return map(int, input().split()) sys.setrecursionlimit(10**9) N, K = mapint() def segfunc(x, y): return max(x, y) ide_ele = -1 class SegTree: """ init(init_val, ide_ele): 配列init_valで初期化 O(N) update(k, x): k番目の値をxに更新 O(logN) ...
s481972572
p02537
u531599639
1601171431
Python
PyPy3 (7.3.0)
py
Runtime Error
154
68672
284
n,k = map(int,input().split()) a = [int(input()) for _ in range(10)] s = set() ans = 0 for i in range(n): cnt = 1 tmp = a[i] for j in range(i+1,n): if j in s: break if abs(a[j]-tmp)<=k: cnt += 1 tmp = a[j] s.add(j) ans = max(ans,cnt) print(ans)
s548557052
p02537
u562767072
1601171403
Python
Python (3.8.2)
py
Runtime Error
348
38772
873
#!/usr/bin/env python3 import os import sys import numpy as np sys.setrecursionlimit(10 ** 9) INF = float("inf") IINF = 10 ** 18 MOD = 10 ** 9 + 7 # MOD = 998244353 def input(): return sys.stdin.readline().rstrip() def main(): n, k = list(map(int, input().split())) A = [] for i in range(n): ...
s059884955
p02537
u129019798
1601171402
Python
PyPy3 (7.3.0)
py
Runtime Error
411
95412
779
def main(): import sys from collections import deque N,M=list(map(int,sys.stdin.readline().split())) dic=[[] for _ in range(100001)] sys.setrecursionlimit(100001) mark=[0]*N for i in range(M): A,B=list(map(int,sys.stdin.readline().split())) dic[A-1].append(B-1) dic[B...
s051683771
p02537
u653026173
1601171359
Python
Python (3.8.2)
py
Runtime Error
2206
15588
191
n,k = map(int, input().split()) #a = list(map(int, input().split())) cnt = [0]*(n+1) for _ in range(n): a = int(input()) cnt[a] = max(cnt[max(0,a-k):min(n,a+k+1)])+1 print(max(cnt))
s314572975
p02537
u250218230
1601171353
Python
Python (3.8.2)
py
Runtime Error
2206
21020
339
n,k = map(int,input().split()) a = [] for num in range(n): a += [int(input())] if (len(a) == 1): print(1) exit() if (len(a) == 2): if abs(a[0] - a[1]) > k: print(1) else: print(2) exit() ch = 0 while (ch < len(a)): #print(a,ch) if abs(a[ch] - a[ch+1]) > k: a.pop(ch+1) ch -= 1 ch += ...
s455576285
p02537
u653026173
1601171328
Python
PyPy3 (7.3.0)
py
Runtime Error
2212
173304
209
#k = int(input()) n,k = map(int, input().split()) #a = list(map(int, input().split())) cnt = [0]*(n+1) for _ in range(n): a = int(input()) cnt[a] = max(cnt[max(0,a-k):min(n,a+k+1)])+1 print(max(cnt))
s822792015
p02537
u252405453
1601171270
Python
Python (3.8.2)
py
Runtime Error
393
24116
516
def rec(pos, a, dp, n, k): if dp[pos] != -1: return dp[pos] for nxt in range(pos + 1, n): if abs(a[pos] - a[nxt]) <= k: dp[pos] = rec(nxt, a, dp, n, k) + 1 return dp[pos] dp[pos] = 1 return 1 def acl_beginner_d(): n, k = map(int, input().split()) a = [] ...
s459375242
p02537
u627600101
1601171183
Python
PyPy3 (7.3.0)
py
Runtime Error
811
98016
2548
#from collections import deque, Counter #from heapq import heapify, heappop, heappush #from bisect import insort #from math import gcd #from decimal import Decimal #mod = 1000000007 #mod = 998244353 #N = int(input()) #####segfunc##### def segfunc(x, y): return max(x, y) ################# #####ide_ele##### ide_ele...
s591862485
p02537
u102655885
1601170979
Python
Python (3.8.2)
py
Runtime Error
435
21728
844
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 abs(current_value - list_a[i]) <...
s379533773
p02537
u557714191
1601170952
Python
Python (3.8.2)
py
Runtime Error
26
9156
354
A = [] for i in range(N): A.append(int(input())) B = [] for j in range(N): B.append(1) for j in range(N): for k in range(j): if A[N-j-1] <= A[N-k-1] and A[N-k-1] - A[N-j-1] <= K: B[N-j-1] = max(B[N-j-1], B[N-k-1] + 1) elif A[N-k-1] < A[N-j-1] and A[N-j-1] - A[N-k-1] <= K: B[N-j-1] = max(B[N...
s664596517
p02537
u782685137
1601170901
Python
Python (3.8.2)
py
Runtime Error
2206
51740
634
from functools import lru_cache import sys sys.setrecursionlimit(30000) @lru_cache(maxsize=30000) def subsolve(i): a = As[i] l=None r=None for j in range(i, 0, -1): if a-k <= As[j-1] <= a and l==None: l = subsolve(j-1)+1 if a < As[j-1] <= a+k and r==None: r = sub...
s691212276
p02537
u631562787
1601170861
Python
PyPy3 (7.3.0)
py
Runtime Error
407
113880
425
n,k=map(int,input().split()) a=list() b=list() c=list() for i in range(0,n): q=int(input()) a.append(q) b.append(a[0]) c.append(a[1]) for i in range(1,n): c=a[i]-a[i-1] c=abs(c) #print(c) if(c<=k): b.append(a[i]) for i in range(2,n): c=a[i]-a[i-1] c=abs(c) #print(c) ...
s333299133
p02537
u691896522
1601170831
Python
Python (3.8.2)
py
Runtime Error
2207
35544
1372
import sys sys.setrecursionlimit(10**7) n,k = map(int, input().split()) a = [] for i in range(n): a.append(int(input())) a.reverse() # dp[i] := i番目の数字から始めたときの最大値 dp = [0 for i in range(n)] #####segfunc###### def segfunc(x,y): return max(x,y) def init(init_val): #set_val for i in range(len(init_val)): ...
s692459746
p02537
u968846084
1601170742
Python
PyPy3 (7.3.0)
py
Runtime Error
774
82260
1043
n,k=map(int,input().split()) #####segfunc###### def segfunc(x,y): return max(x,y) def init(init_val): #set_val for i in range(n): seg[i+num-1]=init_val[i] #built for i in range(num-2,-1,-1) : seg[i]=segfunc(seg[2*i+1],seg[2*i+2]) def update(k,x): k += num-1 seg[k] ...
s846704650
p02537
u252405453
1601170683
Python
PyPy3 (7.3.0)
py
Runtime Error
415
100128
500
def rec(pos, a, dp, n, k): if dp[pos] != -1: return dp[pos] for nxt in range(pos+1, n): if abs(a[pos]-a[nxt])<=k: dp[pos] = rec(nxt,a,dp,n,k)+1 return dp[pos] dp[pos] = 1 return 1 def acl_beginner_d(): n, k = map(int, input().split()) a = [] for _ in r...
s363088562
p02537
u557714191
1601170670
Python
Python (3.8.2)
py
Runtime Error
26
8984
249
A = [] for i in range(N): A.append(int(input())) B = [] for j in range(N): B.append(1) for j in range(N): for k in range(j): if (A[N-j-1] - A[N-k-1])*(A[N-j-1] - A[N-k-1]) <= K*K: B[N-j-1] = max(B[N-j-1], B[N-k-1] + 1) print(max(B))
s227122839
p02537
u782685137
1601170614
Python
Python (3.8.2)
py
Runtime Error
2206
34468
594
from functools import lru_cache @lru_cache(maxsize=40000) def subsolve(i): a = As[i] l=None r=None for j in range(i, 0, -1): if a-k <= As[j-1] <= a and l==None: l = subsolve(j-1)+1 if a < As[j-1] <= a+k and r==None: r = subsolve(j-1)+1 if l!=None and r!=N...
s679699718
p02537
u598296382
1601170606
Python
PyPy3 (7.3.0)
py
Runtime Error
161
78476
288
n,k = map(int,input().split()) low = [0]*(10**5 * 3 + 1) #iで終わる長さ for i in range(n): a = int(input()) for j in range(max(0,a-k),a): low[a] = max(low[a],low[j] + 1) for j in range(a+1,a+k+1): low[a] = max(low[a],low[j] + 1) ans = max(low) print(ans)
s400407390
p02537
u998732100
1601170574
Python
Python (3.8.2)
py
Runtime Error
27
8836
838
#include <bits/stdc++.h> using namespace std; using ll = long long; using Graph = vector<vector<int>>; using pint = pair<int, int>; int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; const int MOD = 1000000007; const long long INF = 1LL << 60; template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; ret...
s412255882
p02537
u054514819
1601170573
Python
PyPy3 (7.3.0)
py
Runtime Error
430
78796
1589
import sys def input(): return sys.stdin.readline().strip() def mapint(): return map(int, input().split()) sys.setrecursionlimit(10**9) N, K = mapint() def segfunc(x, y): return max(x, y) ide_ele = -1 class SegTree: """ init(init_val, ide_ele): 配列init_valで初期化 O(N) update(k, x): k番目の値をxに更新 O(logN) ...
s149928920
p02537
u923172145
1601170373
Python
PyPy3 (7.3.0)
py
Runtime Error
417
93052
2251
#####segfunc##### def segfunc(x, y): return max(x, y) ################# #####ide_ele##### ide_ele = -1 ################# 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...
s605120621
p02537
u733581231
1601170315
Python
Python (3.8.2)
py
Runtime Error
362
209068
1054
#: Author - Soumya Saurav import sys,io,os,time from collections import defaultdict from collections import Counter from collections import deque from itertools import combinations from itertools import permutations import bisect,math,heapq alphabet = "abcdefghijklmnopqrstuvwxyz" input = sys.stdin.readline ##########...
s380269947
p02537
u024340351
1601170276
Python
Python (3.8.2)
py
Runtime Error
400
23304
1027
N, K = map(int, input().split()) A = [] for i in range (0, N): A.append(int(input())) def longest_subseq(n, k, a): # Creating a list with all 0's of size equal to the length of string dp = [0] * n # Supporting list with # all 0's of size 26 since # the given string consists ...
s763430545
p02537
u745514010
1601170233
Python
PyPy3 (7.3.0)
py
Runtime Error
2210
134672
1487
N, k = map(int, input().split()) alst = [int(input()) for _ in range(N)] INF = 0 LV = (N-1).bit_length() N0 = 2**LV data = [INF]*(2*N0) lazy = [None]*(2*N0) def gindex(l, r): L = (l + N0) >> 1; R = (r + N0) >> 1 lc = 0 if l & 1 else (L & -L).bit_length() rc = 0 if r & 1 else (R & -R).bit_length() for...
s407198316
p02537
u161701206
1601170191
Python
Python (3.8.2)
py
Runtime Error
25
9220
160
n,k = map(int,input().split()) ans = [int(input())] for _ in n: a = int(input()) b = int(input()) if a - b >= 3 or b - a >= 3: ans.append(b)
s190263170
p02537
u325227960
1601169970
Python
PyPy3 (7.3.0)
py
Runtime Error
186
83600
286
import sys input = sys.stdin.readline n, k = map(int,input().split()) A = [int(input()) for i in range(n)] from atcoder.segtree import SegTree l = 3*10**5 + 10 S = SegTree(max, 0, l) for i in range(n): S.set(A[i], S.prod(max(0, A[i]-k), min(l, A[i]+k+1)) + 1) print(S.all_prod())
s341947776
p02537
u528045862
1601169845
Python
PyPy3 (7.3.0)
py
Runtime Error
684
80328
2071
#####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...
s452628141
p02537
u615285493
1601169514
Python
PyPy3 (7.3.0)
py
Runtime Error
423
96272
3712
import os import sys from io import BytesIO, IOBase class SegmentTree: def __init__(self, data, default=0, func=max): """initialize the segment tree with data""" self._default = default self._func = func self._len = len(data) self._size = _size = 1 << (self._len - 1).bit_len...
s755927811
p02537
u864197622
1601169387
Python
PyPy3 (7.3.0)
py
Runtime Error
907
119352
5118
import sys input = lambda: sys.stdin.readline().rstrip() class SegmentTreeDual(): def __init__(self, init, initX, unitA, g, h): self.g = g # (X, A, size) -> X self.h = h # (A, A) -> A self.unitA = unitA if type(init) == int: self.n = init self.n = 1 << (self.n...
s468345128
p02537
u467736898
1601169375
Python
Python (3.8.2)
py
Runtime Error
1427
36564
14275
# TODO: 更新ルールの異なる複数のセグ木を作ったときに正しく動くか検証 # TODO: 引数の順番間違えたりすると黙って落ちるのを何とかする # 注: PyPy で普通に書いた方が速い code_segtree = r""" #define PY_SSIZE_T_CLEAN #include <Python.h> #include "structmember.h" // >>> AtCoder >>> #ifndef ATCODER_SEGTREE_HPP #define ATCODER_SEGTREE_HPP 1 #include <algorithm> #ifndef ATCODER_INTERNAL_BITO...
s206695093
p02537
u588341295
1601169361
Python
PyPy3 (7.3.0)
py
Runtime Error
744
118220
3972
import sys def input(): return sys.stdin.readline().strip() def list2d(a, b, c): return [[c for j in range(b)] for i in range(a)] def list3d(a, b, c, d): return [[[d for k in range(c)] for j in range(b)] for i in range(a)] def list4d(a, b, c, d, e): return [[[[e for l in range(d)] for k in range(c)] for j in range(b)]...
s312548933
p02537
u589969467
1601169344
Python
PyPy3 (7.3.0)
py
Runtime Error
425
96796
360
def dfs(i,ans): if i == n: return if len(ans) == 0: ans.append(a[i]) dfs(i+1,ans) else: if abs(ans[-1]-a[i])<=k: ans.append(a[i]) dfs(i+1,ans) n,k = map(int,input().split()) ans = [] a = [] for i in range(n): a.append(int(input())) #print(a) mx = 0 for i in range(n): tmp = [] dfs(...
s041904597
p02537
u875291233
1601169208
Python
PyPy3 (7.3.0)
py
Runtime Error
515
97776
3287
class segment_tree: __slots__ = ["op_M", "e_M","N","N0","dat"] def __init__(self, N, operator_M, e_M): self.op_M = operator_M self.e_M = e_M self.N = N self.N0 = 1<<(N-1).bit_length() self.dat = [self.e_M]*(2*self.N0) # 長さNの配列 initial で初期化 def build(self, ini...