input
stringlengths
20
127k
target
stringlengths
20
119k
problem_id
stringlengths
6
6
import sys def MI(): return list(map(int,sys.stdin.readline().rstrip().split())) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) #空白あり N,K = MI() A = LI() A.sort() def f(n): # Anが必要か否か B = [0] + [A[i] for i in range(N) if i != n] dp = [[0]*K for _ in range(2)] # dp[i][...
import sys def MI(): return list(map(int,sys.stdin.readline().rstrip().split())) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) #空白あり N,K = MI() A = LI() A.sort() def f(n): # Anが必要か否か B = [0] + [A[i] for i in range(N) if i != n] dp = [[0]*K for _ in range(2)] # dp[i][...
p03780
import sys def MI(): return list(map(int,sys.stdin.readline().rstrip().split())) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) #空白あり N,K = MI() A = LI() A.sort() def f(n): # Anが必要か否か B = [0] + [A[i] for i in range(N) if i != n] dp = [[0]*K for _ in range(2)] # dp[i][...
import sys def MI(): return list(map(int,sys.stdin.readline().rstrip().split())) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) #空白あり N,K = MI() A = LI() A.sort() def f(n): # Anが必要か否か B = [0] + [A[i] for i in range(N) if i != n] dp = [0]*K # dp[i][j] = B1~Biを用いてjを作れるか...
p03780
import sys input = sys.stdin.readline N, K = list(map(int, input().split())) a = list(map(int, input().split())) a.sort() def check(x): dp = [0] * (K + 1) dp[0] = 1 for i in range(N): for j in range(K - 1, -1, -1): if i == x: continue if dp[j]: dp[min(K, j + a[i])] = dp[j] ...
import sys input = sys.stdin.readline N, K = list(map(int, input().split())) a = list(map(int, input().split())) a.sort(reverse = True) t = 0 res = -1 for i in range(N): if t + a[i] < K: t += a[i] else: res = i print((N - res - 1))
p03780
N,K = list(map(int,input().split())) a = list(map(int,input().split())) a.sort() if a[0] >= K: print((0)) exit() a = [a[i] for i in range(N) if a[i]<K] N = len(a) ans = N dp = [False]*K dp[0] = True Smax = 0 for i,a_ in reversed(list(enumerate(a))): if Smax + a_ >= K: ans = i up...
N,K = list(map(int,input().split())) a = list(map(int,input().split())) def f(N,K,a): a.sort() if a[0] >= K: print((0)) exit() a = [a[i] for i in range(N) if a[i]<K] N = len(a) ans = N dp = [False]*K dp[0] = True Smax = 0 for i,a_ in reversed(list(enu...
p03780
N,K=list(map(int,input().split())) A=list(map(int,input().split())) A.sort() import bisect idx=bisect.bisect_left(A,K) ans=0 A=A[:idx] N=idx from collections import defaultdict def search(i): dp=defaultdict(int) dp[0]=1 ai=A[i] for j in range(N): dpc=dp.copy() if i==j:cont...
N,K=list(map(int,input().split())) A=list(map(int,input().split())) A.sort(reverse=True) S=0 ans=0 for a in A: if S+a<K: S+=a ans+=1 else:ans=0 print(ans)
p03780
n, k = list(map(int,input().split())) A = list(map(int,input().split())) A.sort() # print(A) le = -1 ri = len(A) mid = (le + ri) // 2 while ri - le > 1: # print(le,ri,mid) DP = [0 for i in range(k)] DP[0] = 1 for i in range(n): #print(DP) if i != mid: for p ...
n, k = list(map(int,input().split())) A = list(map(int,input().split())) A.sort() # print(A) A_set = list(set(A)) A_set = [int(i) for i in A_set] A_set.sort() #print(A_set) le = -1 ri = len(A_set) mid = (le + ri) // 2 while ri - le > 1: need = 0 # print(le,ri,mid) DP = [0 for i in ...
p03780
N,K = list(map(int,input().split())) a = list(map(int,input().split())) dp1 = [[False]*K for _ in range(N)] dp2 = [[False]*K for _ in range(N)] # dp[x][y] x枚目まで使った時にyに出来るか # K-ai <= ai < K となる部分集合を探す dp1[0][0] = True if a[0] < K: dp1[0][a[0]] = True for i in range(1,N): for j in range(K): ...
N,K = list(map(int,input().split())) a = sorted(map(int,input().split())) count = N s = 0 for i in range(N-1,-1,-1): if s + a[i] < K: s += a[i] else: count = min(i,count) print(count)
p03780
# -*- coding: utf-8 -*- import bisect import heapq import math import random import sys from pprint import pprint from collections import Counter, defaultdict, deque import queue from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal from functools import lru_cache, reduce from itertools import combinatio...
# -*- coding: utf-8 -*- import bisect import heapq import math import random import sys from pprint import pprint from collections import Counter, defaultdict, deque import queue from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal from functools import lru_cache, reduce from itertools import combinatio...
p03780
N,K=list(map(int,input().split())) A=list(map(int,input().split())) A.sort() l=N for i in range(0,N): if A[i]>=K: l=i break A=A[:l] N=l #A[num]が必要な数か判定 def condition(num): if N-1>num: test=A[:num]+A[num+1:] else: test=A[:num] if A[num]>=K: retur...
N,K=list(map(int,input().split())) A=list(map(int,input().split())) A.sort() l=N for i in range(0,N): if A[i]>=K: l=i break A=A[:l] N=l #A[num]が必要な数か判定 def condition(num): if N-1>num: test=A[:num]+A[num+1:] else: test=A[:num] if A[num]>=K: retur...
p03780
# -*- 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 ###...
N,K = list(map(int,input().split())) A = list(map(int,input().split())) A.sort(reverse=True) ans = 0 sum = 0 cnt = 0 for i in range(N): a = A[i] if sum+a>=K: ans += cnt+1 cnt = 0 else: sum += a cnt += 1 print((N-ans))
p03780
def I(): return int(eval(input())) def MI(): return list(map(int, input().split())) def LI(): return list(map(int, input().split())) def main(): N,K=MI() a=LI()#下位の連続するn枚が不要なはず a.sort(reverse = True) #i番目までを使ってjが作れるかどうか dp=[[False]*K for _ in range(N+1)] dp[0][0]=1 fo...
def I(): return int(eval(input())) def MI(): return list(map(int, input().split())) def LI(): return list(map(int, input().split())) def main(): N,K=MI() a=LI()#下位の連続するn枚が不要なはず a.sort() #x番目の数が必要かどうかの判定 #必要なものだけで構成された集合をもとに考えれば良いわけではない,不必要な分も考えな...
p03780
def main(): def I(): return int(eval(input())) def MI(): return list(map(int, input().split())) def LI(): return list(map(int, input().split())) N,K=MI() a=LI()#下位の連続するn枚が不要なはず a.sort() for i in range(N):#K以上ならば必要 if a[i]>=K: a=a[:i] break ...
def I(): return int(eval(input())) def MI(): return list(map(int, input().split())) def LI(): return list(map(int, input().split())) def main(): N,K=MI() a=LI()#下位の連続するn枚が不要なはず a.sort() for i in range(N):#K以上ならば必要 if a[i]>=K: a=a[:i] break N=len(a...
p03780
def I(): return int(eval(input())) def MI(): return list(map(int, input().split())) def LI(): return list(map(int, input().split())) def main(): N,K=MI() a=LI()#下位の連続するn枚が不要なはず a.sort() for i in range(N):#K以上ならば必要 if a[i]>=K: a=a[:i] break N=len(a...
def I(): return int(eval(input())) def MI(): return list(map(int, input().split())) def LI(): return list(map(int, input().split())) def main(): N,K=MI() a=LI()#下位の連続するn枚が不要なはず a.sort(reverse=True) #大きい方から順に足していき,K未満の最大の和を作っておく.これに対して,足してK以上になるのならそれは必要.K未満なら端しておく. #最終的に必要なもののうち最も小さ...
p03780
N,K = list(map(int, input().split())) A = [int(a) for a in input().split()] A.sort() def f(n): #aiが必要か不必要か判定 if A[n] >= K: return True if n == 0: L = A[n+1:] elif n == N-1: L = A[:n] else: L = A[:n] + A[n+1:] dp0 = [0]*K dp0[0] = 1 dp1 ...
N,K = list(map(int, input().split())) A = [int(a) for a in input().split()] A.sort() for i in range(N): if A[i] >= K: A = A[:i] break N = len(A) def f(n): #aiが必要か不必要か判定 dp = [0]*K dp[0] = 1 for i in range(N): if i == n: continue for j in ra...
p03780
n,k=list(map(int,input().split())) a=[int(i) for i in input().split()] a.sort() def check(d):#そいつが必要か global a,n,k dp=[0]*(k)#k-1まで if a[d]>=k: return True for i in range(n): if i!=d: dp_sub=[0]*(k) for j in range(k-1): if j==0 or dp[...
N, K = list(map(int, input().split())) a = list(map(int, input().split())) a = sorted(a) ans = N t = 0 for i in range(N-1, -1, -1) : if t+a[i] < K : t += a[i] else : ans = min(ans, i) print(ans)
p03780
import sys input = lambda : sys.stdin.readline().rstrip() sys.setrecursionlimit(max(1000, 10**9)) write = lambda x: sys.stdout.write(x+"\n") n,k = list(map(int, input().split())) a = list(map(int, input().split())) a.sort() def sub(ii): dp = 1 for i in range(n): if i==ii: cont...
import sys input = lambda : sys.stdin.readline().rstrip() sys.setrecursionlimit(max(1000, 10**9)) write = lambda x: sys.stdout.write(x+"\n") n,k = list(map(int, input().split())) a = list(map(int, input().split())) a.sort() def sub(ii): dp = 1 mask = (1<<(k+1)) - 1 for i in range(n): ...
p03780
import sys input = lambda : sys.stdin.readline().rstrip() sys.setrecursionlimit(max(1000, 10**9)) write = lambda x: sys.stdout.write(x+"\n") n,k = list(map(int, input().split())) a = list(map(int, input().split())) a.sort() mask = (1<<(k+1)) - 1 def sub(ii): dp = 1 for i in range(n): if i...
import sys input = lambda : sys.stdin.readline().rstrip() sys.setrecursionlimit(max(1000, 10**9)) write = lambda x: sys.stdout.write(x+"\n") n,k = list(map(int, input().split())) a = list([min(int(x), k+1) for x in input().split()]) a.sort() mask = (1<<(k+1)) - 1 def sub(ii): dp = 1 for i in range...
p03780
# -*- coding: utf-8 -*- import sys from collections import defaultdict from bisect import bisect_left def input(): return sys.stdin.readline().strip() def list2d(a, b, c): return [[c] * b for i in range(a)] def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)] def list4d(a, b, c, d, ...
# -*- coding: utf-8 -*- import sys def input(): return sys.stdin.readline().strip() def list2d(a, b, c): return [[c] * b for i in range(a)] def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)] def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in ...
p03780
import itertools N,K = list(map(int,input().split())) A = list(map(int,input().split())) A.sort() need = [] iranaiko = [] for a in A: if a >= K: need.append(a) elif a in need: need.append(a) elif a in iranaiko: pass else: z = 0 B = A[:] B.remove(a) fusoku = [K - i - 1 for i in range(...
import itertools N,K = list(map(int,input().split())) A = list(map(int,input().split())) A.sort() need = [] iranaiko = [] for a in A: if a >= K: need.append(a) elif a in need: need.append(a) elif a in iranaiko: pass else: z = 0 B = A[:] B.remove(a) fusoku = [K - i - 1 for i in range(...
p03780
import sys stdin = sys.stdin def li(): return [int(x) for x in stdin.readline().split()] def li_(): return [int(x)-1 for x in stdin.readline().split()] def lf(): return [float(x) for x in stdin.readline().split()] def ls(): return stdin.readline().split() def ns(): return stdin.readline().rstrip() def lc(): re...
import sys stdin = sys.stdin def li(): return [int(x) for x in stdin.readline().split()] def li_(): return [int(x)-1 for x in stdin.readline().split()] def lf(): return [float(x) for x in stdin.readline().split()] def ls(): return stdin.readline().split() def ns(): return stdin.readline().rstrip() def lc(): re...
p03780
#import numpy as np MAX_INT = int(10e10) N,K = list(map(int,input().split())) cards = list(map(int,input().split())) cards.sort() cards += [MAX_INT] #print(cards) left = -1 right = N while right - left > 1: middle = (left+right)//2 #print(left,right,middle,cards[middle]) dp = [[0]*K for i in range(N...
#import numpy as np MAX_INT = int(10e10) N,K = list(map(int,input().split())) cards = list(map(int,input().split())) cards.sort() cards += [MAX_INT] #print(cards) dp = [[0]*K for i in range(N+2)] left = -1 right = N while right - left > 1: middle = (left+right)//2 #print(left,right,middle,cards[middle...
p03780
def examA(): N = DI()/dec(7) ans = N print(N) return def examB(): ans = 0 print(ans) return def examC(): ans = 0 print(ans) return def examD(): N, K = LI() A = LI() A.sort() mask = (1 << K) - 1 noneed = -1; need = N while(need-no...
def examA(): N = DI()/dec(7) ans = N print(N) return def examB(): ans = 0 print(ans) return def examC(): ans = 0 print(ans) return def examD(): N, K = LI() A = LI() A.sort() mask = (1 << K) - 1 noneed = -1; need = N while(need-no...
p03780
import sys N,K=list(map(int, input().split())) a=list(map(int, input().split())) sum=0 for i in range(0,N): sum+=a[i] if sum<K:#全部不必要 print(N) sys.exit() if sum==K:#全部必要 print((0)) sys.exit() a.sort() a.reverse() #K未満の最大の数字のラベルはどこ? l=N for i in range(N-1,-1,-1): if a[i]<K: l=i els...
import sys N,K=list(map(int, input().split())) a=list(map(int, input().split())) sum=0 for i in range(0,N): sum+=a[i] if sum<K:#全部不必要 print(N) sys.exit() if sum==K:#全部必要 print((0)) sys.exit() a.sort() a.reverse() #K未満の最大の数字のラベルはどこ? l=N for i in range(N-1,-1,-1): if a[i]<K: l=i el...
p03780
import sys input = sys.stdin.readline def main(): N, K = list(map(int, input().split())) A = list(map(int, input().split())) dp1 = [set() for _ in range(N)] dp1[0].add(0) for n in range(N-1): for pm in dp1[n]: dp1[n+1].add(pm) if pm + A[n] < K: ...
import sys input = sys.stdin.readline def main(): N, K = list(map(int, input().split())) A = list(map(int, input().split())) dp1 = [[0]*K for _ in range(N)] dp1[0][0] = 1 for n in range(N-1): for k in range(K): if k < A[n]: dp1[n+1][k] = dp1[n][k] ...
p03780
# -*- coding:utf-8 -*- from itertools import combinations n,k = list(map(int,input().split())) a = list(map(int, input().split())) a=sorted(a) o=0 discard = [] hold = [] checked = [] # 再帰関数をつくる if sum(a) < k: o = n else: for i in range(n,-1,-1): b = list(combinations(a, i+1)) ...
# -*- coding:utf-8 -*- n,k = list(map(int,input().split())) a = list(map(int, input().split())) a = list(reversed(sorted(a))) nec = 0 for i in range(n): s = 0 for j in range(i,n): s += a[j] if s >= k: nec = max(nec,j+1) s -= a[j] print((n-nec))
p03780
def solve(n): global N, K dp = [[0] * (K + 1) for _ in range(N + 1)] dp[0][0] = 1 for i in range(N): a = 0 if i == n else A[i] for j in range(max(0, K - a + 1)): here = dp[i][j] dp[i + 1][j + a] |= here dp[i + 1][j] |= here rst = any(dp[N...
N, K = list(map(int, input().split())) A = list(map(int, input().split())) A.sort() # [ok, ng) - Maximum # (ng, ok] - Minimum # ok が 最終的な答え ok = N ng = -1 while abs(ok - ng) > 1: mid = (ok + ng) // 2 n = mid dp = [0] * (K + 1) dp[0] = 1 for i in range(N): a = 0 if i == n el...
p03780
def main(): N, K = list(map(int, input().split())) A = list(map(int, input().split())) A.sort() # [ok, ng) - Maximum # (ng, ok] - Minimum # ok が 最終的な答え ok = N ng = -1 while abs(ok - ng) > 1: mid = (ok + ng) // 2 n = mid dp = [0] * (K + 1) ...
def main(): N, K = list(map(int, input().split())) A = list(map(int, input().split())) A.sort() # [ok, ng) - Maximum # (ng, ok] - Minimum # ok が 最終的な答え ok = N ng = -1 while abs(ok - ng) > 1: mid = (ok + ng) // 2 n = mid dp = [0] * (K + 1) ...
p03780
import sys sys.setrecursionlimit(4100000) def biser(lst,func): n=len(lst) nh=n//2 if n==1: if func(lst[0]): return lst[0] else: return -1 if func(lst[nh]): return biser(lst[nh:],func) else: return biser(lst[:nh],func) def fi...
#4 9 #1 3 5 6 #の時に1(正解は0)と出力されるがACになる N, K = list(map(int, input().split())) a=list(map(int, input().split())) a.sort() ans = N t = 0 for i in range(N-1, -1, -1) : if t+a[i] < K: t += a[i] else: ans = min(ans, i) print(ans)
p03780
import sys def biser(lst,func): n=len(lst) nh=n//2 if n==1: if func(lst[0]): return lst[0] else: return -1 if func(lst[nh]): return biser(lst[nh:],func) else: return biser(lst[:nh],func) def mkns(a,s,m): if a==0: ...
import sys def biser(lst,func): n=len(lst) nh=n//2 if n==1: if func(lst[0]): return lst[0] else: return -1 if func(lst[nh]): return biser(lst[nh:],func) else: return biser(lst[:nh],func) def mkns(a,s,m): if a==0: ...
p03780
from itertools import accumulate def main(): N, K = list(map(int, input().split())) As = list(map(int, input().split())) dp = [0] * (K+1) dp[0] = 1 nonzeros = [1] for a in As: ndp = [] nonzero = 0 for i in range(K+1): t = dp[i] if i < a else...
from itertools import accumulate def main(): N, K = list(map(int, input().split())) As = list(map(int, input().split())) nonzeros = [1] for a in As: ndp = nonzeros[-1] if a <= K: ndp |= (nonzeros[-1] % (1 << (K-a))) << a nonzeros.append(ndp) dp =...
p03780
import bisect n, k = list(map(int, input().split())) a = list(map(int, input().split())) a = sorted(a) end = bisect.bisect_right(a, k) a = a[0:end] n = len(a) #rightの部分和の集合を予め求めておく right_subset_sum = [None] * (n+1) right_subset_sum[-1] = set([0]) for i in range(n)[::-1]: a_i = a[i] tmp_set =...
import bisect n, k = list(map(int, input().split())) a = list(map(int, input().split())) a = sorted(a) end = bisect.bisect_right(a, k) a = a[0:end] n = len(a) def subset_sum(mid): if a[mid] >= k: return True dp = [False]*k dp[0] = True for i in range(n): if i == mi...
p03780
import sys input = sys.stdin.buffer.readline def solve(mid): """のぞいてもいいカードならTrueを返す""" dp = [False] * (k + 1) dp[0] = True if k <= a[mid]: return False for i, weight in enumerate(a): if i == mid: continue for w in range(k + 1)[::-1]: if...
import sys input = sys.stdin.buffer.readline def solve(mid): """のぞいてもいいカードならTrueを返す""" dp = 1 mask = (1 << k) - 1 if k <= a[mid]: return False for i, weight in enumerate(a): if i == mid: continue dp |= dp << min(weight, k + 10) dp &= mask ...
p03780
def main(): n,k = list(map(int, input().split())) a = list(map(int, input().split())) a = [i for i in a if i <k] a.sort() n = len(a) DP1 = [[False]*(k+1)] DP1[0][0] = True DP2 = [[False]*(k+1)] DP2[0][0] = True b = a[::-1] for i in range(n): DP1.appe...
def main(): def check(m): DP = [False]*(k+1) DP[0] = True for i in range(n): if i == m: continue for j in reversed(list(range(k+1-a[i]))): DP[a[i]+j] = DP[a[i]+j] or DP[j] return any(DP[i] for i in range(k-a[m], k)) ...
p03780
N, K = list(map(int, input().split())) a = list(map(int, input().split())) a = sorted(a) ans = N for i in range(N-1, -1, -1) : psum = 0 for j in range(i, -1, -1) : if psum+a[j] < K : psum += a[j] else : ans = min(ans, j) print(ans)
N, K = list(map(int, input().split())) a = list(map(int, input().split())) a = sorted(a) ans = N psum = 0 for i in range(N-1, -1, -1) : if psum+a[i] < K : psum += a[i] else : ans = min(ans, i) print(ans)
p03780
n, k = list(map(int, input().split())) a = list(map(int, input().split())) a.sort() l = 0 r = n while l < r: m = (l + r) // 2 if a[m] >= k: r = m continue dp = [[0 for _ in range(k)] for _ in range(n)] dp[0][0] = 1 t = 1 check = 0 for i in range(n): ...
n, k = list(map(int, input().split())) a = list(map(int, input().split())) a.sort() l = 0 r = n while l < r: m = (l + r) // 2 if a[m] >= k: r = m continue dp = set() dp.add(0) check = 0 for i in range(n): next = set() if i == m: c...
p03780
n, k = list(map(int, input().split())) a = list(map(int, input().split())) a.sort() l = 0 r = n while l < r: m = (l + r) // 2 if a[m] >= k: r = m continue dp = [set() for _ in range(n + 1)] dp[0].add(0) check = 0 for i in range(n): if i == m: ...
n, k = list(map(int, input().split())) a = list(map(int, input().split())) a.sort(reverse=True) temp = 0 ans = 0 for x in a: if temp + x < k: temp += x ans += 1 else: ans = 0 print(ans)
p03780
from itertools import accumulate n,k = list(map(int,input().split())) a = list(map(int,input().split())) a.sort() acc = list(accumulate(a)) def maxsum(ls,k): l = len(ls) if l==0: return 0 dp = [0 for i in range(l+1)] dp[0] = 1 for i in range(1,l+1): dp[i] = dp[i-1]|(dp[i-1]<<ls[i-1]) ...
from itertools import accumulate n,k = list(map(int,input().split())) a = list(map(int,input().split())) a.sort() acc = list(accumulate(a)) def maxsum(ls,k): l = len(ls) if l==0: return 0 dp = [0 for i in range(l+1)] dp[0] = 1 for i in range(1,l+1): dp[i] = (dp[i-1]|(dp[i-1]<<ls[i-1]))&(...
p03780
import sys N, K = list(map(int, input().split())) A = list(map(int, input().split())) #A = [i for i in range(1,2)] + [i for i in range(2,1001)] * 4 A.sort() DP = [0 for k in range(K+1)] #和がkとなる部分集合の数 DP[0] = 1 for a in A: for k in range(K-a,-1,-1): DP[k+a] += DP[k] """ for k in range(1,2*K+1): #累積和...
import sys N, K = list(map(int, input().split())) A = list(map(int, input().split())) #A = [i for i in range(1,2)] + [i for i in range(2,1001)] * 4 A.sort() DP = [0 for k in range(K+1)] #和がkとなる部分集合の数 DP[0] = 1 for a in A: for k in range(K-a,-1,-1): DP[k+a] += DP[k] """ for k in range(1,2*K+1): #累積和...
p03780
#!/usr/bin/env python3 import sys INF = float("inf") def solve(N: int, K: int, a: "List[int]"): a.sort() if a[0] >= K: print((0)) return a = [x for x in a if x < K] N = len(a) ng = -1 ok = N while abs(ok - ng) > 1: j = (ok + ng) // 2 # ...
#!/usr/bin/env python3 import sys INF = float("inf") def solve(N: int, K: int, a: "List[int]"): a.sort() if a[0] >= K: print((0)) return a = [x for x in a if x < K] N = len(a) ng = -1 ok = N while abs(ok - ng) > 1: j = (ok + ng) // 2 # ...
p03780
#!/usr/bin/env python from collections import deque import itertools as it import sys import math sys.setrecursionlimit(1000000) MOD = 10 ** 30 + 7 N, M = list(map(int, input().split())) s = input() p27 = [1 for i in range(500000)] for i in range(1, 500000): p27[i] = p27[i - 1] * 27 p27[i] %...
#!/usr/bin/env python from collections import deque import itertools as it import sys import math sys.setrecursionlimit(1000000) MOD = 10 ** 30 + 7 N, M = list(map(int, input().split())) s = input() p27 = [1 for i in range(500000)] for i in range(1, 500000): p27[i] = p27[i - 1] * 27 p27[i] %...
p01558
from sys import stdin nii=lambda:list(map(int,stdin.readline().split())) lnii=lambda:list(map(int,stdin.readline().split())) n,d=nii() print(((n+d*2+1-1)//(d*2+1)))
from sys import stdin nii=lambda:list(map(int,stdin.readline().split())) lnii=lambda:list(map(int,stdin.readline().split())) n,d=nii() num=d*2+1 print(((n+num-1)//num))
p02970
import math n,d=list(map(int,input().split())) a=n/(2*d+1) print((math.ceil(a)))
n,d=list(map(int,input().split())) a=n/(2*d+1) import math b=math.ceil(a) print(b)
p02970
n,d=list(map(int,input().split())) p=0 while n>0: n-=(d*2+1) p+=1 print((str(p)))
def people(n): p=0 while n>0: n-=(d*2+1) p+=1 return p def main(): print((people(n))) if __name__=='__main__': n,d=list(map(int,input().split())) main()
p02970
a,b=list(map(int,input().split())) print(((a-1)//(2*b+1)+1))
n,d=list(map(int,input().split())) d=2*d+1 print((0--n//d))
p02970
# 2019-11-15 14:12:24(JST) import sys # import collections import math # from string import ascii_lowercase, ascii_uppercase, digits # from bisect import bisect_left as bi_l, bisect_right as bi_r # import itertools # from functools import reduce # import operator as op # from scipy.misc import comb # float # ...
import sys n, d = list(map(int, sys.stdin.readline().split())) def main(): c = 2*d + 1 return (n + c - 1) // c if __name__ == '__main__': ans = main() print(ans)
p02970
N, D = list(map(int, input().split())) print(((N + 2 * D)//(2 *D + 1)))
N, D = list(map(int, input().split())) tmp = 2 * D + 1 print(((N + tmp - 1) // tmp))
p02970
import sys sys.setrecursionlimit(10 ** 9) # input = sys.stdin.readline #### def int1(x): return int(x) - 1 def II(): return int(eval(input())) def MI(): return list(map(int, input().split())) def MI1(): return list(map(int1, input().split())) def LI(): return list(map(int, input().split())) def LI1(): return...
import sys sys.setrecursionlimit(10 ** 9) # input = sys.stdin.readline #### def int1(x): return int(x) - 1 def II(): return int(eval(input())) def MI(): return list(map(int, input().split())) def MI1(): return list(map(int1, input().split())) def LI(): return list(map(int, input().split())) def LI1(): return...
p02970
import math n,d=list(map(int,input().split())) print((math.ceil(n/(d*2+1))))
n,d=list(map(int,input().split())) if n%(d*2+1): print((n//(d*2+1)+1)) else: print((n//(d*2+1)))
p02970
n, d = list(map(int, input().split())) x = 2*d+1 #監視可能範囲 if n%x == 0: print((n//x)) else: print((n//x + 1))
n, d = list(map(int, input().split())) dist = 2 * d + 1 if n%dist != 0: print((n//dist + 1)) else: print((n//dist))
p02970
n, d = list(map(int, input().split())) ans = 0 n -= (d+1) # 一人目の立つ場所 ans += 1 if n <= 0: print(ans) exit() while True: if (n - d) <= 0: break else: n -= (2*d + 1) ans += 1 if n <= 0: break print(ans)
import math N, D = list(map(int, input().split())) print((math.ceil(N/(2*D+1))))
p02970
n,d=list(map(int,input().split())) l=d+1 r=n-d if l==r: print((1)) else: ans=1 k=l while k<r: k+=2*d+1 ans+=1 print(ans)
n,d=list(map(int,input().split())) print(((n+2*d)//(2*d+1)))
p02970
import math n, d = list(map(int, input().split())) cnt = 0 print((math.ceil(n/(2*d+1))))
import math n, d = list(map(int, input().split())) print((math.ceil(n/(2*d+1))))
p02970
n,d=list(map(int,input().split())) print((n//(2*d+1)+(n%(2*d+1)>0)))
n,d=list(map(int,input().split())) print((n//(d+d+1)+(n%(d+d+1)>0)))
p02970
from decimal import Decimal,ROUND_HALF_UP n,d = list(map(int,input().split())) x = (n+d*2)//(d*2+1) print(x)
n,d = list(map(int,input().split())) x = (n+d*2)//(d*2+1) print(x)
p02970
N, D = list(map(int, input().split())) ans = 0 i = D+1 while True: ans += 1 if D+i >= N: break i += 2*D + 1 print(ans)
N, D = list(map(int, input().split())) if N % (2*D+1) == 0: print((N // (2*D+1))) else: print((int(N // (2*D+1)) + 1))
p02970
# B - Golden Apple from math import ceil N, D = list(map(int, input().split())) print((ceil(N/(2*D+1))))
# B - Golden Apple N, D = list(map(int, input().split())) # print(int((N+2*D)/(2*D+1))) print(((N+2*D)//(2*D+1)))
p02970
import math N, D = list(map(int, input().split())) ob_range = 2 * D + 1 print((math.ceil(N / ob_range)))
import math N, D = list(map(int, input().split())) print((math.ceil(N / (2 * D + 1))))
p02970
N, Z, W = list(map(int, input().split())) *A, = list(map(int, input().split())) import sys sys.setrecursionlimit(10**6) memo = {} def dfs(i, turn): if (i, turn) in memo: return memo[i, turn] if turn == 0: # X if i == 0: res = abs(W - A[-1]) else: ...
N, Z, W = list(map(int, input().split())) *A, = list(map(int, input().split())) if N == 1: print((abs(A[0] - W))) else: print((max(abs(A[-1] - W), abs(A[-2] - A[-1]))))
p03552
# どちらか必ずa_Nのカードを持つ import sys from functools import lru_cache sys.setrecursionlimit(4000) N,Z,W = list(map(int,input().split())) A = list(map(int,input().split())) A.reverse() # turn: true->X, false->Y BOTTOM = A[0] @lru_cache(maxsize=2000000) def rec_X(i,y): return max(abs(BOTTOM-y),max((rec_Y(j,A...
# どちらか必ずa_Nのカードを持つ N,Z,W = list(map(int,input().split())) A = list(map(int,input().split())) A.reverse() A.append(W) BOTTOM = A[0] M = float('inf') m = 0 for a in A[1:]: x = abs(BOTTOM-a) t = max(x,m) s = min(x,M) M = min(M,t) m = max(m,s) print(t)
p03552
import sys sys.setrecursionlimit(10 ** 6) int1 = lambda x: int(x) - 1 p2D = lambda x: print(*x, sep="\n") def main(): def score(i,x,y,turn): if i==n-1: return abs(x-y) if (i,x,y,turn) in memo: return memo[(i,x,y,turn)] if turn: res=0 ...
import sys sys.setrecursionlimit(10 ** 6) int1 = lambda x: int(x) - 1 p2D = lambda x: print(*x, sep="\n") def MI(): return map(int, sys.stdin.readline().split()) def LI(): return list(map(int, sys.stdin.readline().split())) def main(): n, z, w = MI() aa = LI() if n - 2 >= 0: print(...
p03552
import sys N, Z, W = list(map(int, input().split())) A = list(map(int, input().split())) inf = 10 ** 9 + 7 sys.setrecursionlimit(inf) def calc(a, b): return abs(a - b) def alphaBeta(X, Y, turn, depth, alpha, beta): if depth == N: return calc(X, Y) if turn: for i in range...
import sys N, Z, W = list(map(int, input().split())) A = list(map(int, input().split())) ans = abs(A[-1] - W) if N != 1: ans = max(ans, abs(A[-1] - A[-2])) print(ans)
p03552
#!usr/bin/env python3 from collections import defaultdict,deque from heapq import heappush, heappop import sys import math import bisect import random def LI(): return [int(x) for x in sys.stdin.readline().split()] def I(): return int(sys.stdin.readline()) def LS():return [list(x) for x in sys.stdin.readline()...
#!usr/bin/env python3 from collections import defaultdict,deque from heapq import heappush, heappop import sys import math import bisect import random def LI(): return [int(x) for x in sys.stdin.readline().split()] def I(): return int(sys.stdin.readline()) def LS():return [list(x) for x in sys.stdin.readline()...
p03552
import sys sys.setrecursionlimit(10 ** 6) def dfs(x, y, memo, A, N, Z, W): X = Z if x == 0 else A[x - 1] Y = W if y == 0 else A[y - 1] if memo[x][y] >= 0: return memo[x][y] else: if x == N or y == N: rst = abs(X - Y) else: if x <= y: ...
N, Z, W = list(map(int, input().split())) A = list(map(int, input().split())) dp = [[-1] * (N + 1) for _ in range(N + 1)] for x in range(N, -1, -1): for y in range(N, -1, -1): if x == y: continue X = Z if x == 0 else A[x - 1] Y = W if y == 0 else A[y - 1] if x ...
p03552
N, C = list(map(int, input().split())) programs = [[0 for _ in range(C)] for _ in range(2*10**5)] for _ in range(N): s, t, c = list(map(int, input().split())) for i in range(2*s-1, 2*t): programs[i][c-1] = 1 ret = 0 for i in range(2*10**5): ret = max(ret, sum(programs[i])) print(ret)
N, C = list(map(int, input().split())) programs = [[0 for _ in range(C)] for _ in range(10**5)] for _ in range(N): s, t, c = list(map(int, input().split())) for i in range(s-1, t): programs[i][c-1] = 1 ret = 0 for i in range(10**5): ret = max(ret, sum(programs[i])) print(ret)
p03504
def main(): N,C = list(map(int, input().split())) # 各時間各チャンネルで録画機が動いてるかどうか R = [[0]*(10**5) for _ in range(C)] for _ in range(N): s,t,c = list(map(int, input().split())) #チャンネルcをsからtまで録画、sの0.5秒前から録画機を使うのでs-1始まりにする R[c-1][s-1:t] = [1] * (t-(s-1)) ans ...
def main(): N,C = list(map(int, input().split())) # 各時間各チャンネルで録画機が動いてるかどうか R = [[0]*(10**5) for _ in range(C)] for _ in range(N): s,t,c = list(map(int, input().split())) #チャンネルcをsからtまで録画、sの0.5秒前から録画機を使うのでs-1始まりにする R[c-1][s-1:t] = [1] * (t-(s-1)) ans ...
p03504
N,C = list(map(int,input().split())) tv_times = [[int(j) for j in input().split()] for i in range(N)] channells = {} for i in range(C+1): channells[i] = [] max_end = -1 for i in range(N): s,g,c = tv_times[i] max_end = max(max_end,g) channells[c] += [s,g] tv_times = [] f = [0 for i in ra...
N,C = list(map(int,input().split())) tv_times = [[int(j) for j in input().split()] for i in range(N)] channells = {} for i in range(C+1): channells[i] = [] max_end = -1 for i in range(N): s,g,c = tv_times[i] max_end = max(max_end,g) channells[c] += [s,g] tv_times = [] f = [0 for i in ra...
p03504
N, C = list(map(int, input().split())) TV = [[0]*(2*10**5) for i in range(C)] for i in range(N): s, t, c = list(map(int, input().split())) TV[c-1][2*s-2] += 1 TV[c-1][2*t-1] -= 1 for i in range(C): for j in range(1, 2*10**5): TV[i][j] = TV[i][j]+TV[i][j-1] for i in range(C): ...
from itertools import accumulate N, C = list(map(int, input().split())) G = [[0] * (10 ** 5 + 1) for i in range(C)] for i in range(N): s, t, c = list(map(int, input().split())) c = c - 1 G[c][s - 1] += 1 G[c][t] -= 1 for i in range(C): G[i] = list(accumulate(G[i])) ans = 0 for i in ra...
p03504
n, c = list(map(int, input().split())) stc = [] for _ in range(n): stc.append(tuple(map(int, input().split()))) sm = [0 for _ in range(2 * (pow(10, 5) + 1))] for _c in range(c): tt = [0 for _ in range(2 * (pow(10, 5) + 1))] for s, t, c in stc: if c == _c + 1: tt[s * 2 - 1] += 1 tt[t * ...
import sys input = sys.stdin.readline from heapq import heappop, heappush def main(): n, c = list(map(int, input().split())) stc = [] for _ in range(n): stc.append(tuple(map(int, input().split()))) stc = list(sorted(stc, key=lambda x: (x[2], x[0]))) restc = [] prev = stc[0] for _stc in ...
p03504
def main(): from itertools import accumulate n, c, *stc = list(map(int, open(0).read().split())) table = [0] * 2 * (10 ** 5 + 1) m = list(zip(stc[::3], stc[1::3], stc[2::3])) m.sort(key=lambda a: (a[2], a[0], a[1])) ch_ = 0 t_ = 0 for s, t, ch in m: if ch != ch_: ...
def main(): from itertools import accumulate n, c, *stc = list(map(int, open(0).read().split())) table = [0] * (10 ** 5 + 2) m = list(zip(stc[::3], stc[1::3], stc[2::3])) m.sort(key=lambda a: (a[2], a[0], a[1])) ch_ = 0 t_ = 0 for s, t, ch in m: if ch != ch_: ...
p03504
def main(): from itertools import accumulate n, c, *stc = list(map(int, open(0).read().split())) table = [0] * (10 ** 5 + 2) m = list(zip(stc[::3], stc[1::3], stc[2::3])) m.sort(key=lambda a: (a[2], a[0], a[1])) ch_ = 0 t_ = 0 for s, t, ch in m: if ch != ch_: ...
def main(): from itertools import accumulate n, c, *stc = list(map(int, open(0).read().split())) table = [0] * (10 ** 5 + 2) m = sorted(list(zip(*[iter(stc)] * 3)), key=lambda a: (a[2], a[0], a[1])) ch_ = 0 t_ = 0 for s, t, ch in m: if ch != ch_: ch_ = ch ...
p03504
def main(): from itertools import accumulate n, c, *stc = list(map(int, open(0).read().split())) table = [0] * (10 ** 5 + 2) m = sorted(list(zip(*[iter(stc)] * 3)), key=lambda a: (a[2], a[0], a[1])) ch_ = 0 t_ = 0 for s, t, ch in m: if ch != ch_: ch_ = ch ...
def main(): from itertools import accumulate n, c, *stc = list(map(int, open(0).read().split())) table = [0] * (10 ** 5 + 2) m = sorted(list(zip(*[iter(stc)] * 3)), key=lambda a: (a[2], a[0])) ch_ = 0 t_ = 0 for s, t, ch in m: if ch != ch_: ch_ = ch ...
p03504
n, c = list(map(int, input().split())) cnt = [[0 for _ in range(c)] for j in range(10 ** 5 + 1)] cnt_sum = [0] * (10 ** 5 + 1) for _ in range(n): s, t, _c = list(map(int, input().split())) cnt[s - 1][_c - 1] += 1 cnt[t][_c - 1] -= 1 for i in range(1, 10 ** 5 + 1): for j in range(c): cnt...
n, c = list(map(int, input().split())) cnt = [[0 for _ in range(10 ** 5 + 1)] for _ in range(c)] for _ in range(n): s, t, _c = list(map(int, input().split())) for j in range(s, t + 1): cnt[_c - 1][j] = 1 ans = 0 for i in range(10 ** 5 + 1): ans = max(ans, sum(cnt[j][i] for j in range(c))) ...
p03504
N,C=list(map(int,input().split())) from collections import defaultdict cannel={i:[] for i in range(1,1+C)} check=[tuple(map(int,input().split())) for i in range(N)] check.sort(key=lambda x:x[0]) for x in check: s,t,c=x if cannel[c]==[]: cannel[c].append((max(0,s-1),t)) elif s-cannel[c][-1][...
N,C=list(map(int,input().split())) from collections import defaultdict Cbef=defaultdict(int) time=defaultdict(int) TV=[tuple(map(int,input().split())) for i in range(N)] TV.sort(key=lambda x:x[0]) for s,t,c in TV: if Cbef[c]==s: time[s]+=1 time[t]-=1 Cbef[c]=t else: t...
p03504
n, c = list(map(int, input().split())) r = [[0 for i in range(c)] for j in range(100000)] # テレビ局の番組表 for dummy in range(n): # 入力 s, t, c = list(map(int, input().split())) for j in range(s - 1, t): r[j][c - 1] = 1 # 放送中なら1 ans = 0 for i in range(100000): if sum(r[i]) > ans: an...
N, C = list(map(int, input().split())) r = [[0] * C for _ in range(10 ** 5)] for _ in range(N): s, t, c = list(map(int, input().split())) for i in range(s - 1, t): r[i][c - 1] = 1 ans = 0 for t in r: sum_t = sum(t) if sum_t > ans: ans = sum_t print(ans)
p03504
#!/usr/bin/env python3 #ABC80 D import sys import math import bisect sys.setrecursionlimit(1000000000) from heapq import heappush, heappop,heappushpop from collections import defaultdict from itertools import accumulate from collections import Counter from collections import deque from operator import item...
#!/usr/bin/env python3 #ABC80 D import sys import math import bisect sys.setrecursionlimit(1000000000) from heapq import heappush, heappop,heappushpop from collections import defaultdict from itertools import accumulate from collections import Counter from collections import deque from operator import item...
p03504
import sys import math from itertools import accumulate as acc N,C=list(map(int,input().split())) a=[[0 for i in range(10**5+1)] for i in range(C+1)] rec=[0 for i in range(10**5+1)] for i in range(N): s,t,c=list(map(int,input().split())) recs,rect=a[c][s],a[c][t] if recs==0 and rect==0: ...
import sys import math from itertools import accumulate as acc input=sys.stdin.readline N,C=list(map(int,input().split())) a=[[0 for i in range(10**5+1)] for i in range(C+1)] rec=[0 for i in range(10**5+1)] for i in range(N): s,t,c=list(map(int,input().split())) recs,rect=a[c][s],a[c][t] ...
p03504
import sys import math from itertools import accumulate as acc input=sys.stdin.readline N,C=list(map(int,input().split())) a=[[0 for i in range(10**5+1)] for i in range(C+1)] rec=[0 for i in range(10**5+1)] for i in range(N): s,t,c=list(map(int,input().split())) recs,rect=a[c][s],a[c][t] ...
import sys import math from itertools import accumulate as acc input=sys.stdin.readline N,C=list(map(int,input().split())) a=[[0 for i in range(10**5+1)] for i in range(C+1)] rec=[0 for i in range(10**5+1)] for i in range(N): s,t,c=list(map(int,input().split())) recs,rect=a[c][s],a[c][t] ...
p03504
N_C = list(map(int, input().split())) s_t_c = [] for i in range(N_C[0]): s_t_c.append(list(map(int, input().split()))) max_number = 0 for j in range(10 ** 5): number = 0 for k in range(N_C[0]): if s_t_c[k][0] <= j - 1 and s_t_c[k][1] >= j: number = number + 1 if s_t_c...
n, C = list(map(int, input().split())) time = 0 stc = [] for i in range(n): temp = list(map(int, input().split())) time = max(time, temp[1]) stc.append(temp) tv = [[0 for i in range(C)] for i in range(time + 1)] for i in stc: s, t, c = i[0], i[1], i[2] for j in range(s, t + 1): tv...
p03504
N, C = list(map(int, input().split())) M = 10 ** 5 * 2 + 5 T = [[0] * M for i in range(C)] for i in range(N): s, t, c = list(map(int, input().split())) s = 2 * s - 1 t = 2 * t c -= 1 T[c][s] += 1 T[c][t] -= 1 TT = [[0] * (2 * N) for i in range(C)] for i in range(C): for j in ra...
N, C = list(map(int, input().split())) M = 200005 rec = [[0] * M for i in range(C)] for i in range(N): s, t, c = list(map(int, input().split())) rec[c - 1][2 * s - 1] += 1 rec[c - 1][2 * t] -= 1 for j in range(C): for i in range(1, M): rec[j][i] += rec[j][i - 1] num = 0 for j in r...
p03504
n,c = list(map(int,input().split())) stc = [[int(i) for i in input().split()] for j in range(n)] ans = 0 stc.sort(key=lambda x:(x[2],x[1],x[0])) time = 10**5+3 c_imos = [[0 for i in range(time)] for j in range(c)] for i in range(n): c_imos[stc[i][2]-1][stc[i][0]-1] += 1 c_imos[stc[i][2]-1][stc...
n,c = list(map(int,input().split())) stc = [[int(i) for i in input().split()] for j in range(n)] ans = 0 stc.sort(key=lambda x:(x[2],x[1],x[0])) time = 10**5+1 c_imos = [[0 for i in range(time)] for j in range(c)] for i in range(n): for j in range(stc[i][1]-stc[i][0]+1): c_imos[stc[i][2]-1...
p03504
T_MAX = 10**5 n, nc = list(map(int, input().split())) stc = [list(map(int, input().split())) for _ in range(n)] nrecs = [0]*(2*T_MAX+1) for c in range(1, nc+1): rec = [0]*(2*T_MAX+1) for i in range(n): if stc[i][2] == c: rec[stc[i][0]*2-1] += 1 rec[stc[i][1]*2] -= 1 ...
T_MAX = 10**5 n, nc = list(map(int, input().split())) stc = [list(map(int, input().split())) for _ in range(n)] recs = [[0]*(T_MAX+1) for c in range(nc+1)] for s, t, c in stc: recs[c][s-1:t] = [1]*(t-s+1) ans = max(list(map(sum, list(zip(*recs))))) print(ans)
p03504
N,C=list(map(int,input().split())) Time=[[0]*(10**5+1)]*C for i in range(N): s,t,c=list(map(int,input().split())) T_c=list(Time[c-1]) T_c[s-1:t]=[1]*(t-s+1) Time[c-1]=list(T_c) Times=max(list(map(sum,list(zip(*Time))))) print(Times)
N,C=list(map(int,input().split())) Time=[[0]*(10**5+1) for c in range(C)] for i in range(N): s,t,c=list(map(int,input().split())) Time[c-1][s-1:t] = [1]*(t-s+1) Times=max(list(map(sum,list(zip(*Time))))) print(Times)
p03504
import sys import math import collections import itertools import array import inspect # Set max recursion limit sys.setrecursionlimit(10000) # Debug output def chkprint(*args): names = { id(v): k for k, v in list(inspect.currentframe().f_back.f_locals.items()) } print(('...
import sys import math import collections import itertools import array import inspect # Set max recursion limit sys.setrecursionlimit(10000) # Debug output def chkprint(*args): names = { id(v): k for k, v in list(inspect.currentframe().f_back.f_locals.items()) } print(('...
p03504
N,C = list(map(int,input().split())) A = [[0 for _ in range(C)] for j in range(200001)] for i in range(N): s,t,c = list(map(int,input().split())) for j in range(s*2-1,t*2): A[j][c-1] = 1 R = 0 for i in range(200001): sumA = sum(A[i]) if R < sumA: R = sumA print(R)
N,C = list(map(int,input().split())) A = [[0 for _ in range(C)] for j in range(100001)] for i in range(N): s,t,c = list(map(int,input().split())) for j in range(s-1,t): A[j][c-1] = 1 R = 0 for i in range(100001): sumA = sum(A[i]) if R < sumA: R = sumA print(R)
p03504
N,C = list(map(int,input().split())) STC = [[] for _ in range(C)] for i in range(N): s,t,c = list(map(int,input().split())) STC[c-1].append((s,t)) lenA = 200001 A = [[0]*lenA for _ in range(C)] for i in range(N): a = 1 for i in range(C): for (s,t) in STC[i]: A[i][s*2-1] += 1 ...
N,C = list(map(int,input().split())) STC = [[] for _ in range(C)] for i in range(N): s,t,c = list(map(int,input().split())) STC[c-1].append((s,t)) lenA = 200001 A = [[0]*lenA for _ in range(C)] for i in range(C): for (s,t) in STC[i]: A[i][s*2-1:t*2] = [1]*(t*2-s*2+1) Ans = [0]*lenA fo...
p03504
N, C = list(map(int, input().split())) TVs = [[] for i in range(C)] for i in range(N): s, t, c = list(map(int, input().split())) TVs[c - 1].append((s, t)) periods = [0] * (2 * 10 ** 5) for c, TVc in enumerate(TVs): ps = [0] * (2 * 10 ** 5) for s, t in TVc: ps[s * 2 - 1: t * 2 - 2 ...
import heapq N, C = list(map(int, input().split())) TVs = [[] for i in range(C)] for i in range(N): s, t, ch = list(map(int, input().split())) TVs[ch - 1].append((s, t)) pq = [] for ch, TVc in enumerate(TVs): if not TVc: continue TVc.sort() heapq.heappush(pq, (TVc[0][0] - 0.5, ch)) ...
p03504
from itertools import accumulate N, C = list(map(int, input().split())) STC = [list(map(int, input().split())) for _ in range(N)] M = 10**5+1 merge = [[0]*(M+1) for _ in range(31)] for i in range(N): s, t, c = STC[i] merge[c][s] += 1 merge[c][t+1] -= 1 for c in range(31): merge[c] = list([in...
from itertools import accumulate N, C = list(map(int, input().split())) STC = [list(map(int, input().split())) for _ in range(N)] M = 10**5+1 merge = [[0]*(M+1) for _ in range(31)] for i in range(N): s, t, c = STC[i] #merge[c][s] += 1 #merge[c][t+1] -= 1 merge[c][s:t+1] = [1]*(t-s+1) #for c ...
p03504
ri = lambda: int(input()) rl = lambda: list(map(int,input().split())) rr = lambda N: [ri() for _ in range(N)] YN = lambda b: print('YES') if b else print('NO') yn = lambda b: print('Yes') if b else print('No') OE = lambda x: print('Odd') if x%2 else print('Even') INF = 10**18 N,C=rl() st = [[] for _ in range(...
ri = lambda: int(input()) rl = lambda: list(map(int,input().split())) rr = lambda N: [ri() for _ in range(N)] YN = lambda b: print('YES') if b else print('NO') yn = lambda b: print('Yes') if b else print('No') OE = lambda x: print('Odd') if x%2 else print('Even') INF = 10**18 N,C=rl() stc = [rl() for _ in ran...
p03504
from collections import defaultdict from itertools import accumulate n, v = list(map(int, input().split())) programs = defaultdict(list) for _ in range(n): s, t, c = list(map(int, input().split())) programs[c].append((s, t)) imos = [0] * (2 * 10 ** 5 + 2) for c, p in list(programs.items()): p.s...
from collections import defaultdict from itertools import accumulate n, v = list(map(int, input().split())) programs = defaultdict(list) for _ in range(n): s, t, c = list(map(int, input().split())) programs[c].append((s, t)) imos = [0] * (10 ** 5 + 2) for c, p in list(programs.items()): p.sort(...
p03504
N, C = list(map(int, input().split())) tt = [[0] * (2 * 10 ** 5 + 1) for _ in range(30)] for _ in range(N): s, t, c = list(map(int, input().split())) ttc = tt[c - 1] for i in range(s * 2 - 1, t * 2): ttc[i] = 1 ct = [0] * (2 * 10 ** 5 + 1) for i in range(30): tti = tt[i] for j ...
from operator import itemgetter N, C = list(map(int, input().split())) stc = [list(map(int, input().split())) for _ in range(N)] stc.sort(key=itemgetter(2, 0)) cs = [0] * (10 ** 5 * 2 + 1) pc = -1 for s, t, c in stc: if pc != c: pt = -1 pc = c if pt == s: cs[s * 2] += 1 ...
p03504
N, C = list(map(int, input().split())) tt = [[0] * (10 ** 5 + 1) for _ in range(30)] for _ in range(N): s, t, c = list(map(int, input().split())) ttc = tt[c - 1] for i in range(s - 1, t): ttc[i] = 1 ct = [0] * (10 ** 5 + 1) for i in range(30): tti = tt[i] for j in range(10 ** 5...
# imos 法 from operator import itemgetter N, C = list(map(int, input().split())) stc = [list(map(int, input().split())) for _ in range(N)] stc.sort(key=itemgetter(2, 0)) cs = [0] * (10 ** 5 + 1) pc = -1 for s, t, c in stc: if pc != c: pt = -1 pc = c if pt == s: cs[s] += 1 ...
p03504
N, C = list(map(int, input().split())) tt = [[0] * (10 ** 5 + 1) for _ in range(C)] for _ in range(N): s, t, c = list(map(int, input().split())) for i in range(s - 1, t): tt[c - 1][i] = 1 ct = [0] * (10 ** 5 + 1) for i in range(C): for j in range(10 ** 5 + 1): ct[j] += tt[i][j] ...
# imos 法 from operator import itemgetter N, C = list(map(int, input().split())) stc = [list(map(int, input().split())) for _ in range(N)] stc.sort(key=itemgetter(2, 0)) cs = [0] * (10 ** 5 + 1) pt, pc = -1, -1 for s, t, c in stc: if pt == s and pc == c: cs[s] += 1 else: cs[s - 1] ...
p03504
N, C = list(map(int, input().split())) prog = [] for _ in range(N): prog.append(list(map(int, input().split()))) ans = 0 T = 10**5 print((max([len(list([x for x in prog if x[0] <= i <= x[1]])) for i in range(T+1)])))
from itertools import accumulate # -*- coding: utf-8 -*- # python template for atcoder1 import sys sys.setrecursionlimit(10**9) input = sys.stdin.readline N, C = list(map(int, input().split())) TV = dict() programs = [list(map(int, input().split())) for _ in range(N)] last_time = max([p[1] for p in programs]...
p03504
N, C = list(map(int, input().split())) channels = [[] for _ in range(C)] maxT = 0 for _ in range(N) : s, t, c = list(map(int, input().split())) maxT = max(maxT, t) channels[c - 1].append((s, t)) maxT = maxT * 2 + 10 tvSum = [0 for _ in range(maxT)] for tv in channels : imos = [0 for _ ...
N, C = list(map(int, input().split())) channels = [[] for _ in range(C)] maxT = 0 for _ in range(N) : s, t, c = list(map(int, input().split())) maxT = max(maxT, t) channels[c - 1].append((s, t)) maxT = maxT * 2 + 10 tvSum = [0 for _ in range(maxT)] for tv in channels : imos = [0 for _ ...
p03504
import sys def main(): input = sys.stdin.readline N, C = list(map(int, input().split())) dic = [[] for _ in range(C + 1)] for _ in range(N): s, t, c = input().split() dic[int(c)].append([int(s), int(t)]) for c in range(C + 1): l = len(dic[c]) if l == 1: ...
import sys def main(): input = sys.stdin.readline N, C = list(map(int, input().split())) dic = [[] for _ in range(C + 1)] for _ in range(N): s, t, c = input().split() dic[int(c)].append([int(s), int(t)]) for c in range(C + 1): l = len(dic[c]) if l == 1: ...
p03504
n,c = list(map(int,input().split())) program = [list(map(int,input().split())) for i in range(n)] time = [0 for i in range(10**5+1)] program.sort() program.sort(key = lambda x: x[2]) for i in range(1,n): if program[i][2]==program[i-1][2] and program[i][0]==program[i-1][1]: program[i][0] = progra...
n,c = list(map(int,input().split())) ab = [] for _ in range(n): s, t, cha = (int(x) for x in input().split()) ab.append([s, t, cha]) ab = sorted(ab, key=lambda x: x[0]) ab = sorted(ab, key=lambda x: x[2]) for i in range(1,n): if ab[i][0] == ab[i-1][1] and ab[i][2] == ab[i-1][2]: ab[i][0...
p03504
import functools N, C = list(map(int, input().split())) T = [[0 for i in range(10 ** 5 + 1)] for j in range(C)] for i in range(N): s, t, c = list(map(int, input().split())) for j in range(s - 1, t): T[c - 1][j] = 1 ans = 0 for j in range(10 ** 5 + 1): r = 0 for i in range(C): r += T[i][j] ...
import functools N, C = list(map(int, input().split())) P = [[0 for c in range(C)] for i in range(10 ** 5 + 1)] T = 0 for i in range(N): s, t, c = list(map(int, input().split())) T = max(t, T) for j in range(s - 1, t): P[j][c - 1] = 1 ans = 0 for p in P[:T + 1]: ans = max(sum(p), ans) print(ans)
p03504
N, C = list(map(int, input().split())) stc = [[int(x) for x in input().split()] for _ in range(N)] im = [[0] * (10**5 + 1) for _ in range(C + 1)] for x in stc: s,t,c = x im[c][s] += 1 im[c][t] -= 1 for c in range(1, C + 1): v = 0 for i in range(1, 10**5 + 1): n = im[c][i] ...
import operator N, C = list(map(int, input().split())) stc = [[int(x) for x in input().split()] for _ in range(N)] united = [] pc,ps,pt = 0,0,0 for x in sorted(stc, key=operator.itemgetter(2,0,1)): s, t, c = x if c == pc and s == pt: united[-1][1] = t else: united.append([s, t, c...
p03504
N, C = list(map(int, input().split())) channel_list = [[0 for _ in range(10**5+1)]for _ in range(C)] count_list = [0 for _ in range(10**5+1)] for i in range(N): s, t, c = list(map(int, input().split())) channel_list[c-1][s-1] += 1 channel_list[c-1][t] -= 1 for i in range(C): for t in range(1, ...
N, C = list(map(int, input().split())) channel_list = [[0 for _ in range(10**5+1)]for _ in range(C)] count_list = [0 for _ in range(10**5+1)] for i in range(N): s, t, c = list(map(int, input().split())) channel_list[c-1][s-1] += 1 channel_list[c-1][t] -= 1 for i in range(C): for t in range(1, ...
p03504
N, C = list(map(int, input().split())) channel_list = [[0 for _ in range(10**5+1)]for _ in range(C)] count_list = [0 for _ in range(10**5+1)] for i in range(N): s, t, c = list(map(int, input().split())) channel_list[c-1][s-1] += 1 channel_list[c-1][t] -= 1 for i in range(C): for t in range(1, ...
N, C = list(map(int, input().split())) time = 10**5+1 channel_list = [[0 for _ in range(time)]for _ in range(C)] count_list = [0 for _ in range(time)] for i in range(N): s, t, c = list(map(int, input().split())) channel_list[c-1][s-1] += 1 channel_list[c-1][t] -= 1 for i in range(C): for t in...
p03504