description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
testCase = int(input()) def func(arr, k): t, cnt = -1, 0 for i in range(len(arr)): if arr[i] != t: cnt += 1 t = arr[i] if cnt == k + 1: return [0] * i + [(j - arr[i - 1]) for j in arr[i:]] return [0] * len(arr) for tc in range(testCase): m, flag = 0, 0...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR IF VAR BIN_OP VAR NUMBER RETURN BIN_OP BIN_OP LIST NUMBER VAR BIN_OP VAR VAR BIN_OP VAR NUMBER VAR VAR VAR RETURN BIN_OP LIST NUMBER FUNC_CALL VAR VAR FOR VAR...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
for _ in range(int(input())): n, k = map(int, input().split()) a = list(map(int, input().split())) if k == 1 and [a[0]] * n != a: print(-1) continue cnt = 0 while a.count(0) != n: cnt += 1 b = [a[0]] for i in range(1, n): if a[i] == b[-1]: ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER BIN_OP LIST VAR NUMBER VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER WHILE FUNC_CALL VAR NUMBER VAR VAR NUMBER ASSIGN VAR LIST...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
import sys def main(): T = int(input()) for ti in range(T): n, k = map(int, input().split()) A = set(int(v) for v in input().split()) if k == 1: if len(A) == 1: print(1) else: print(-1) continue if len(A) == 1:...
IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF FUNC_CALL VAR ...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
import sys input = lambda: sys.stdin.readline().rstrip("\r\n") t = int(input()) for _ in range(t): n, k = map(int, input().split()) a = [int(x) for x in input().split()] cnt = 0 for i in range(1, n): if a[i] - a[i - 1] != 0: cnt += 1 if k == 1 and cnt >= 1: print(-1) ...
IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF BIN_OP VAR VAR VAR BIN_OP VAR NUMBER N...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
import sys input = sys.stdin.readline t = int(input()) for _ in range(t): n, k = map(int, input().split()) arr = list(map(int, input().split())) if k == 1: if len(set(arr)) != 1: print(-1) else: print(1) continue else: ans = 1 pos = 0 ...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER IF FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER A...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
import sys def minp(): return sys.stdin.readline().strip() def mint(): return int(minp()) def mints(): return map(int, minp().split()) def solve(): n, k = mints() p = -5 q = -1 for i in mints(): if i != p: q += 1 p = i if k == 1: if q > 0: ...
IMPORT FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR IF VAR VAR VAR NUMBER ASSIGN VAR VAR IF VAR NUMBER IF VAR NUMBER EXPR FUNC_...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
n = int(input()) for i in range(n): a, b = [int(i) for i in input().split()] c = [int(i) for i in input().split()] e = b count = 1 if len(set(c)) == b: print(1) elif b - 1 == 0: print(-1) else: while e < len(set(c)): e = e + (b - 1) count = cou...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER IF FUNC_CALL VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_C...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
t = int(input()) for _ in range(t): n, k = [int(x) for x in input().split()] a = [int(x) for x in input().split()] x = len(set(a)) if k == 1: if x > 1: ans = -1 else: ans = 1 elif x <= k: ans = 1 else: x -= k ans = 1 ans += ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR ASSIGN VAR NUMBER V...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
def ceil(a, b): return (a + b - 1) // b def solve(): N, K = map(int, input().split()) A = set([int(x) for x in input().split()]) if K == 1: return 1 if len(A) == 1 else -1 if len(A) <= K: return 1 return ceil(len(A) - K, K - 1) + 1 TC = int(input()) for _ in range(TC): pr...
FUNC_DEF RETURN BIN_OP BIN_OP BIN_OP VAR VAR NUMBER VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER RETURN FUNC_CALL VAR VAR NUMBER NUMBER NUMBER IF FUNC_CALL VAR VAR VAR RETURN NUMBER RETURN BIN_OP FUNC_CALL VAR ...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
t = int(input()) for i in range(t): n, k = map(int, input().strip().split(" ")) lst = list(map(int, input().strip().split(" "))) l = len(list(set(lst))) if k == 1 and l > 1: print(-1) else: j = 1 while True: p1 = k * j - (j - 1) p2 = k * (j + 1) - j ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL ...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
t = int(input()) for tc in range(t): n, k = map(int, input().split()) a = list(map(int, input().split())) if len(set(a)) <= k: print(1) elif k == 1: print(-1) else: print(int((len(set(a)) - k - 0.1) // (k - 1) + 2))
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF FUNC_CALL VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR FUNC_CA...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
t = int(input()) for _ in range(t): n, k = map(int, input().split()) a = list(map(int, input().split())) temp = len(set(a)) if k != 1: r = temp + k - 3 print(max(1, r // (k - 1))) elif temp == 1: print(1) else: print(-1)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR N...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
for t in range(int(input())): n, k = map(int, input().split()) a = list(map(int, input().split())) a.append(-9) count = 0 for i in range(n): if a[i] != a[i + 1]: count += 1 plus, score = 0, 0 if k == 1 and count > 1: print(-1) continue while True: ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER IF ...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
def ceil_div(y, k): return (y + (k - 1)) // k t = int(input()) for i in range(t): n, k = map(int, input().split()) a = list(map(int, input().split())) b = set(a) d = len(b) zero = False for x in b: if x == 0: zero = True if k == 1: if d > 1: prin...
FUNC_DEF RETURN BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
t = int(input()) for _ in range(t): n, k = map(int, input().split()) a = list(map(int, input().split())) if k == 1: f = True for i in range(1, n): if a[i] != a[i - 1]: f = False if f: print(1) else: print(-1) continu...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER IF VAR EXPR FUN...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
t = int(input()) ans = [] for _ in range(t): n, k = [int(i) for i in input().split()] A = [int(i) for i in input().split()] if k == 1: if len(set(A)) != 1: ans += [-1] else: ans += [1] elif len(set(A)) <= k: ans += [1] else: if (len(set(A)) - k...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER IF FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER VAR LIST NUMBER VAR LIST NUMBER IF FUNC_CALL VAR FUNC_CALL VAR VA...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
t = int(input()) for _ in range(t): n, k = list(map(int, input().split())) arr = list(map(int, input().split())) lis = [0] * 101 for i in range(n): lis[arr[i]] = 1 a = lis.count(1) if k == 1 and a > 1: print(-1) else: s = 0 while a > k: a -= k - 1 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUM...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
for i in range(int(input())): n, k = [int(num) for num in input().split()] x = list(map(int, input().split())) if len(set(x)) <= k: print(1) elif k < 2: print(-1) else: c = len(set(x)) c1 = c - k c1 = c1 // (k - 1) if (c - k) % (k - 1) == 0: ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF FUNC_CALL VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VA...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
t = int(input()) for _ in range(t): n, k = map(int, input().split(" ")) a = list(map(int, input().split(" "))) s = set(a) num = len(s) if k == 1 and num > 1: print(-1) else: num -= k k -= 1 count = 1 while num > 0: num -= k count +=...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER VAR VAR ...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
ans = [] for t in range(int(input())): n, k = map(int, input().split()) (*a,) = map(int, input().split()) h = {} for v in a: h[v] = True u = len(h) if k == 1: ans.append(1 if u == 1 else -1) else: ans.append(max(1, (u - 1 + k - 2) // (k - 1))) for a in ans: print(...
ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER NUMBER NUMBER EXPR FU...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
for _ in range(int(input())): n, k = map(int, input().split()) a = list(map(int, input().split())) a = list(set(a)) a.sort() count = 1 if k == 1 and len(a) > 1: print(-1) else: while sum(a) != 0: if len(a) < k: count += 1 break ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER IF VAR NUMBER FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER W...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
t = int(input()) for i in range(t): n, k = map(int, input().split()) length = len(set(input().split(" "))) if k == 1 and length > 1: print(-1) elif k >= length: print(1) else: length -= k k -= 1 print((length + k - 1) // k + 1)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR NUMBER VAR VAR VAR NUMBER EXPR FUNC_CALL VAR BI...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
import sys input = sys.stdin.readline for _ in range(int(input())): n, k = map(int, input().split()) a = list(map(int, input().split())) if k == 1: if n == 1: print(1) elif all(a[i] == a[0] for i in range(n)): print(1) else: print(-1) cont...
IMPORT ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR NUMBER VAR FUNC_CALL VAR VAR EXPR FUNC_CA...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
from sys import stdin input = stdin.readline for _ in range(int(input())): n, k = map(int, input().split()) a = list(map(int, input().split())) cnt = len(set(a)) if k == 1 and cnt > 1: print(-1) continue cnt = max(0, cnt - k) if cnt == 0: print(1) continue an...
ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER BIN_O...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
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...
IMPORT FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FUNC_DEF RETURN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FUNC_DEF RETURN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FUNC_DEF NUMBER...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
import sys input = sys.stdin.readline inp, ip = lambda: int(input()), lambda: [int(w) for w in input().split()] for _ in range(inp()): n, k = ip() x = ip() dis = len(set(x)) if dis <= k: print(1) continue if 0 in x and dis > 1 and k == 1: print(-1) continue if k ...
IMPORT ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER IF NUMBER VAR VAR NUMBER VAR NUMBER EXP...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
def solve(): n, k = map(int, input().split()) a = list(map(int, input().split())) if n == 1: print(1) return diff = 1 ans = 1 for i, v in enumerate(a): if i > 0: if v == a[i - 1]: continue else: diff += 1 ...
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER RETURN ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR VAR NUMBE...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
import sys input = sys.stdin.readline I = lambda: list(map(int, input().split())) (t,) = I() for _ in range(t): n, k = I() l = I() st = len(set(l)) m = 1 if k == 1 and st != 1: m = -1 elif k >= st: m = 1 else: m = 1 + (st - 2) // (k - 1) print(m)
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR ASSIGN VAR ...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
(T,) = map(int, input().split()) for _ in range(T): N, K = map(int, input().split()) X = list(map(int, input().split())) if K == 1: if len(set(X)) == 1: print(1) else: print(-1) continue b = 0 vs = set() c = 0 R = 1 for x in X: if x...
ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER IF FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VA...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
for query in range(int(input())): nk = input().split() n = int(nk[0]) k = int(nk[1]) a = [(int(x) - 1) for x in input().split()] x = [False] * 101 count = 0 for y in range(n): x[a[y]] = True for y in range(101): if x[y]: count += 1 if count != 1 and k == 1...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR ...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
for _ in range(int(input())): n, k = map(int, input().split()) a = [int(x) for x in input().split()] l = len(set(a)) if l == 1: print(1) elif l <= k: print(1) elif k == 1 and l != 1: print(-1) else: ans = 0 sumi = -1 while sumi != 0: ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_C...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
def solve(A, n, k): prev = -1 dist = [] for it in A: if it != prev: dist.append(it) prev = it td = len(dist) if k == 1: if td == 1: return 1 else: return -1 if td <= k: return 1 ans = (td - 2) // (k - 1) + 1 ...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER IF VAR NUMBER RETURN NUMBER RETURN NUMBER IF VAR VAR RETURN NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER NUMBER RETURN VAR FOR VAR FUNC_CALL VAR FUNC_...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
TC = int(input()) for tc in range(TC): N, K = map(int, input().split()) A = list(map(int, input().split())) result = 0 tmp = A.copy() noZeros = True while noZeros: noZeros = False count = 0 last = -1 for i in range(N): if count >= K: if...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VA...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
for _ in range(int(input())): n, k = map(int, input().split(" ")) ans = 0 arr = [int(num) for num in input().split(" ")] if k == 1 and len(set(arr)) != 1: ans = -1 elif arr[0] == 0 and len(set(arr)) == 1: ans = 1 else: while arr[0] != 0 or len(set(arr)) != 1: ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING IF VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR ...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
testcases = int(input()) for testcase in range(testcases): temparr = input() temparr = temparr.split() n = int(temparr[0]) k = int(temparr[1]) temparr = input() temparr = temparr.split() arr = [] dicts = {} for i in temparr: arr.append(int(i)) dicts[i] = 1 if k ==...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR DICT FOR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR AS...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
t = int(input()) for i in range(t): n, k = map(int, input().split()) a = list(map(int, input().split())) if k == 1 and len(set(a)) > 1: print(-1) else: m = 0 while a != [0] * n: k1 = k tmp = -1 for i in range(n): if k1 > 0 and a...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP LIST NUMBER VAR A...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
( lambda W: [ ( lambda N, K, n: ( print(1 if all(n[i] == n[i + 1] for i in range(N - 1)) else -1) if K == 1 else ( lambda b, k: ( lambda ns, bs, ks: print( len( ...
EXPR FUNC_CALL FUNC_CALL VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR NUMBER NUMBER FUNC_CALL VAR NUMBER NUMBER VAR NUMBER VAR FUNC_CALL VAR VAR ...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
t = int(input()) while t: n, k = map(int, input().split()) a = list(map(int, input().split())) ans = 0 flag = 0 while True: s = list(set(a)) s.sort() if len(s) >= k: val = s[k - 1] else: val = s[-1] if val == 0 and len(s) > 1: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR IF FUNC_CALL VAR VAR VAR ASSIGN VAR ...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
from sys import stdin T = int(stdin.readline().strip()) for caso in range(T): n, k = map(int, stdin.readline().strip().split()) a = list(map(int, stdin.readline().strip().split())) x = len(set(a)) - k if x <= 0: print(1) continue if k == 1: print(-1) continue ans...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR ...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
for _ in range(int(input())): n, k = map(int, input().split()) data = set(map(int, input().split())) if len(data) > 1 and k == 1: print(-1) elif len(data) <= k: print(1) elif (len(data) - k) % (k - 1) == 0: print(1 + (len(data) - k) // (k - 1)) else: print(1 + (le...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF FUNC_CALL VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER IF BIN_OP BIN_OP FUNC_CALL VAR...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
t = int(input()) for _ in range(t): n, k = map(int, input().split()) A = list(map(int, input().split())) c = len(set(A)) if k - 1 == 0: if c - 1 > 0: print(-1) else: print(1) else: ans = (c - 1 + (k - 1) - 1) // (k - 1) print(max(1, ans))
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER EXPR F...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
import sys z = sys.stdin.readline for _ in range(int(input())): n, k = map(int, z().split()) a = [*map(int, z().split())] s = len(set(a)) print(1 - 2 * (s > 1) if k < 2 else max(1, -((1 - s) // (k - 1))))
IMPORT ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR NUMBER BIN_OP NUMBER BIN_OP NUMBER VAR NUMBER FUNC_CALL VAR NUMBER ...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
def calc(sa, k): if sa == k: return 1 if k == 1 and sa > 1: return -1 result = 0 if sa > k: sa -= k result += 1 result += sa // (k - 1) if sa % (k - 1) != 0: result += 1 return result T = int(input()) for t in range(T): st = input().split() k...
FUNC_DEF IF VAR VAR RETURN NUMBER IF VAR NUMBER VAR NUMBER RETURN NUMBER ASSIGN VAR NUMBER IF VAR VAR VAR VAR VAR NUMBER VAR BIN_OP VAR BIN_OP VAR NUMBER IF BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIG...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
for _ in range(int(input())): n, k = map(int, input().split()) a = set([int(x) for x in input().split()]) if k == 1: print(-1 if len(a) > 1 else 1) else: print(max(1, (len(a) + k - 2 - 1) // (k - 1)))
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP BIN_OP BIN_OP FU...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
import sys input = sys.stdin.readline def main(): t = int(input()) for _ in range(t): N, K = [int(x) for x in input().split()] A = [int(x) for x in input().split()] acnt = len(set(A)) if K == 1 and acnt != 1: print(-1) continue acnt -= K ...
IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER VAR VAR IF V...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
t = int(input()) for _ in range(t): n, k = map(int, input().split()) a = list(map(int, input().split())) s = set() def arrsum(): s.clear() m = 1 for i in range(n): s.add(a[i]) if len(s) == k: break sm = 0 for i in range(n):...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_DEF EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR IF FUNC...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
import sys sys.setrecursionlimit(10**5) int1 = lambda x: int(x) - 1 p2D = lambda x: print(*x, sep="\n") def II(): return int(sys.stdin.readline()) def MI(): return map(int, sys.stdin.readline().split()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [...
IMPORT EXPR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR STRING FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
for _ in range(int(input())): n, k = map(int, input().split()) l = list(map(int, input().split())) d = {} ans = 1 for i in l: d[i] = d.get(i, 0) + 1 if k == 1: if len(d) != 1: print(-1) else: print(ans) elif len(d) <= k: print(ans) ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER IF VAR NUMBER IF FUNC_CALL VAR VAR NUMBER EXPR...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
t = int(input()) for _ in range(t): n, k = map(int, input().split()) l = list(map(int, input().split())) ll = list(set(l)) if k == 1 and len(ll) == 1: print(1) elif k == 1 and len(ll) != 1: print(-1) else: d = len(ll) c = 0 while d > k: d = d -...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR NUMBER FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER FUNC_CALL...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
def mi(): return map(int, input().split()) for _ in range(int(input())): n, k = mi() a = list(set(list(mi()))) uniq = len(a) if k == 1: if uniq > 1: print(-1) else: print(1) continue if uniq <= k: print(1) continue uniq -= k ...
FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR ...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
t = int(input()) for j in range(t): n, k = map(int, input().split()) a = list(map(int, input().split())) r = set(a) e = len(r) - k if k == 1 and len(r) != 1: print(-1) elif k == 1 and len(r) == 1: print(1) elif e <= 0: print(1) elif e % (k - 1) == 0: print...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR IF VAR NUMBER FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMB...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
t = int(input()) for _ in range(t): n, k = map(int, input().split()) inp = [int(j) for j in input().split()] cnt = 0 flag = 0 while 1: temp = list(set(inp)) temp.sort() if len(temp) >= k: minVal = temp[k - 1] else: minVal = temp[-1] if ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR IF FUNC_CALL VAR VAR VAR ASSIG...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
for _ in range(int(input())): N, M = [int(i) for i in input().split(" ")] A = [int(i) for i in input().split(" ")] count = 1 for i in range(1, N): if A[i] != A[i - 1]: count += 1 if M == 1: if count == 1: print(1) else: print(-1) elif M...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL ...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
for _ in range(int(input())): n, k = map(int, input().split()) A = list(map(int, input().split())) if k == 1 and len(set(A)) != 1: print(-1) continue m = 0 while True: m += 1 used = 1 if m > 1 else 0 last = 0 if m > 1 else -1 for i in range(n): ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER NUM...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
t = int(input()) for _ in range(t): n, k = map(int, input().split()) a = list(map(int, input().split())) s = set(a) if len(s) > 1 and k == 1: print(-1) continue if len(s) <= k: print(1) continue ans = 1 + (len(s) - k) // (k - 1) if (len(s) - k) % (k - 1): ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF FUNC_CALL VAR VAR VAR EXPR FUNC_CA...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
t = int(input()) for _ in range(t): n, k = map(int, input().split()) a = [int(x) for x in input().split()] aS = set(a) u = len(aS) answer = 0 if 0 not in aS: u -= min(k - 1, u - 1) answer += 1 k -= 1 if k == 0: if u == 1: print(answer) else: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF NUMBER VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMB...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
t = int(input()) for you in range(t): l = input().split() n = int(l[0]) k = int(l[1]) l = input().split() li = [int(i) for i in l] if k == 1: poss = 1 for i in li: if i != li[0]: poss = 0 break if poss: print(1) ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR NUMBER ASSIGN VAR NUM...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
t = int(input()) for i in range(t): n, k = map(int, input().split()) lst = list(map(int, input().split())) s = set(lst) l = len(s) if k == 1 and l > 1: print(-1) elif k == 1 and l == 1: print(1) elif k < l: if (l - 1) % (k - 1) == 0: print((l - 1) // (k - ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER VAR NUMB...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
def solve(n, k, arr): num = len(set(arr)) if k == 1: if num == 1: return 1 return -1 if num <= k: return 1 return (num + k - 3) // (k - 1) t = int(input()) for i in range(t): n, k = map(int, input().split()) arr = list(map(int, input().split())) print(so...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR NUMBER IF VAR NUMBER RETURN NUMBER RETURN NUMBER IF VAR VAR RETURN NUMBER RETURN BIN_OP BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSI...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
for _ in range(int(input())): n, k = list(map(int, input().split())) l = list(map(int, input().split())) dist = len(set(l)) if dist <= k: print(1) continue if k == 1: print(-1) else: ans = (dist - k) // (k - 1) + 1 if (dist - k) % (k - 1): ans ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR B...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
for _ in range(int(input())): n, k = map(int, input().split()) a = list(map(int, input().split())) a1 = set(a) d = len(a1) j = 0 m = 0 tot = 0 while tot < d and k - (j > 0) > 0: t = k - (j > 0) tot += t m += 1 j += 1 if tot < d: print(-1) e...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR BIN_OP VAR VAR NUMBE...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
for i in range(int(input())): n, k = map(int, input().split()) a = list(map(int, input().split())) g = [0] * 105 for j in range(n): g[a[j]] = g[a[j]] + 1 c = 0 for j in range(105): if g[j] > 0: c = c + 1 if c <= k: print("1") elif k == 1 and c > 1: ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR BIN_OP VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VA...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
a = int(input()) for k in range(0, a): b = list(map(int, input().split())) h = list(map(int, input().split())) if h.count(h[0]) != len(h) and b[1] == 1 and len(h) > 1: print(-1) else: c = [] for i in range(0, len(h)): if h[i] not in c: c.append(h[i]) ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR VAR NUMBER NUMBER FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
import sys input = sys.stdin.readline for _ in range(int(input())): n, k = map(int, input().split()) a = list(map(int, input().split())) cnt = 0 for i in range(1, n): if a[i] > a[i - 1]: cnt += 1 if k == 1: if [a[0]] * n == a: print(1) else: ...
IMPORT ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR NUMBER IF BIN_OP LIST ...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
for t in range(int(input())): n, k = map(int, input().split()) v = list(map(int, input().split())) fv = [0] * 101 for x in v: fv[x] += 1 dist = 0 for i in range(0, 101): if fv[i] > 0: dist += 1 k = min(k, dist) if k == 1: print(-1 if dist > 1 else 1) ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER IF VAR VAR NUMBER VAR NUMBER...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
game = int(input()) for i in range(game): n, k = map(int, input().split()) a = list(map(int, input().split())) b = set(a) p = len(b) q = 0 count = 0 j = 1 if k == 1: if p == 1: print(1) else: print(-1) elif p <= k: print(1) else: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER IF VA...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
a = int(input()) for i in range(a): n, k = map(int, input().split()) z = list(map(int, input().split())) ans = list(set(z)) if len(ans) > 1 and k == 1: print(-1) continue else: t = len(ans) cnt = 0 flag = 0 while 1: if flag == 0: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VA...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
from sys import setrecursionlimit, stdin, stdout class Tail_Recursion_Optimization: def __init__(self, RECURSION_LIMIT, STACK_SIZE): setrecursionlimit(RECURSION_LIMIT) threading.stack_size(STACK_SIZE) return None class SOLVE: def solve(self): R = stdin.readline W = ...
CLASS_DEF FUNC_DEF EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR RETURN NONE CLASS_DEF FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
from sys import * input = stdin.readline for _ in range(int(input())): n, k = map(int, input().split()) a = list(map(int, input().split())) start = a[0] cn = 1 dsnt = 1 flag = 1 for i in a: if i != start and k != 1 and dsnt == k: cn += 1 dsnt = 2 ...
ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR NUMBER VAR VAR VAR NUMBER AS...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
def solution(n, k, a): res = 1 if k == 1: for i in range(1, n): if a[i] != a[0]: return -1 return 1 cnt = 1 cur = a[0] for index in range(1, n): if cur == a[index]: continue if cnt == k: res += 1 cnt = 1 ...
FUNC_DEF ASSIGN VAR NUMBER IF VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR NUMBER RETURN NUMBER RETURN NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FU...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
for _ in range(int(input())): n, k = map(int, input().split()) arr = list(map(int, input().split())) arr = list(set(arr)) arr.sort() n = len(arr) if k >= 1 and n == 1: print(1) continue if k == 1 and n > 1: print(-1) continue c = len(arr) - 1 ans = c /...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF V...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
for _ in range(int(input())): n, k = [int(i) for i in input().split()] a = [int(i) for i in input().split()] b = [] while True: b_i = [] ind = 0 for num in range(k): b_i.append(a[ind]) for ind_a, el in enumerate(a): if ind != ind_a: ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST WHILE NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR FOR VAR VAR FUNC_CALL VAR VAR IF VAR...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
t = int(input()) for _ in range(t): n, k = map(int, input().split()) a = list(map(int, input().split())) if k == 1 and len(set(a)) > 1: print(-1) else: s = set() prev = None result = 1 for x in a: if x != prev: s.add(x) ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NONE ASSIGN VAR ...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
t = int(input()) for i in range(t): n, k = map(int, input().split()) a = list(map(int, input().split())) if k == 1 and len(set(a)) > 1: print(-1) elif k == 1: print(1) else: c = 0 while True: if c == 1: k -= 1 for j in range(k):...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR N...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
t = int(input()) for _ in range(t): n, k = map(int, input().split()) a = [int(i) for i in input().split()] st = set(a) if k == 1 and len(st) > 1: print(-1) continue res = 0 b = [0] * n b[0] = a[0] while True: kek1 = 0 kek = 0 for i in range(1, n): ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
mod = 10**9 + 7 def solve(): ans = -1 n, k = map(int, input().split()) a = list(map(int, input().split())) d = {} for x in a: d[x] = 1 if k == 1: if len(d) != 1: ans = -1 else: ans = 1 else: l = len(d) ans = max((l + k - 3) //...
ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR VAR ASSIGN VAR VAR NUMBER IF VAR NUMBER IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NU...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
def is_sorted(li): temp = list(li) for i in range(0, len(li)): if li[i] != temp[i]: return False return True def process(): n, k = list(map(int, input().split())) li = list(map(int, input().split())) if is_sorted(li) == False: print("-1") return elif k =...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR VAR VAR RETURN NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CAL...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
T = int(input()) while T > 0: n, k = map(int, input().split()) arr = list(map(int, input().split())) index = 0 count = 0 ss = 0 prev = -1 res = 0 find = True while index < n: temp = arr[index] - ss if prev == temp: index += 1 continue e...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP ...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
for _ in range(int(input())): n, k = map(int, input().split()) A = [int(x) for x in input().split()] if k == 1: flag = 0 for i in A: if A[0] != i: flag = 1 if flag == 1: print(-1) else: print(1) else: x = set(A) ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER VAR ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR...
You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$ is equal to $n$ for all $1 \leq i \leq m$. For all $1 \leq j \leq...
t = int(input()) while t > 0: n, k = map(int, input().split()) a = [int(i) for i in input().split()] a = set(a) count = len(a) ans = 0 if k == 1 and count > 1: print(-1) else: ans = 1 count -= k k -= 1 while count > 0: count -= k ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER VAR V...
This is an easier version of the problem. In this version, $n \le 2000$. There are $n$ distinct points in three-dimensional space numbered from $1$ to $n$. The $i$-th point has coordinates $(x_i, y_i, z_i)$. The number of points $n$ is even. You'd like to remove all $n$ points using a sequence of $\frac{n}{2}$ snaps....
n = int(input()) coordinates = [] for i in range(n): coordinates.append([int(i) for i in input().split()]) coordinates[i].append(i + 1) coordinates.sort() remaining = [] i = 0 while i < len(coordinates): if i < len(coordinates) - 1 and coordinates[i][:2] == coordinates[i + 1][:2]: print(coordinates[...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR VAR NUMBE...
This is an easier version of the problem. In this version, $n \le 2000$. There are $n$ distinct points in three-dimensional space numbered from $1$ to $n$. The $i$-th point has coordinates $(x_i, y_i, z_i)$. The number of points $n$ is even. You'd like to remove all $n$ points using a sequence of $\frac{n}{2}$ snaps....
import sys def main(): n = int(sys.stdin.readline()) points = [None] * n for i in range(n): x, y, z = map(int, sys.stdin.readline().split()) points[i] = [x, y, z, i] points.sort() for _ in range(n // 2): best = 1 for i in range(2, len(points)): x1 = abs(...
IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NONE VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR LIST VAR VAR VAR VAR EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC...
This is an easier version of the problem. In this version, $n \le 2000$. There are $n$ distinct points in three-dimensional space numbered from $1$ to $n$. The $i$-th point has coordinates $(x_i, y_i, z_i)$. The number of points $n$ is even. You'd like to remove all $n$ points using a sequence of $\frac{n}{2}$ snaps....
n = int(input()) a = [tuple(map(int, input().split())) for _ in range(n)] s = {a[q]: (q + 1) for q in range(n)} a.sort() q, q1 = 0, 1 d, d1, d2 = [[[a[0]]]], [], [] while q1 < n: while q1 < n and a[q][0] == a[q1][0]: while q1 < n and a[q][1] == a[q1][1]: d[-1][-1].append(a[q1]) q1 +=...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR VAR LIST LIST LIST VAR NUMBER LIST LIST WHILE VAR VAR WHILE VAR VAR VA...
This is an easier version of the problem. In this version, $n \le 2000$. There are $n$ distinct points in three-dimensional space numbered from $1$ to $n$. The $i$-th point has coordinates $(x_i, y_i, z_i)$. The number of points $n$ is even. You'd like to remove all $n$ points using a sequence of $\frac{n}{2}$ snaps....
n = int(input()) li = [] for i in range(n): a, b, c = map(int, input().split()) li.append([a, b, c, i + 1]) li.sort() i = 0 l = len(li) a = [] while i < l: if i < l - 1 and li[i][:2] == li[i + 1][:2]: print(li[i][3], li[i + 1][3]) i += 2 else: a.append(li[i]) i += 1 li = ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST WHILE VAR VAR IF VAR BIN_OP VAR NUMBER VAR...
This is an easier version of the problem. In this version, $n \le 2000$. There are $n$ distinct points in three-dimensional space numbered from $1$ to $n$. The $i$-th point has coordinates $(x_i, y_i, z_i)$. The number of points $n$ is even. You'd like to remove all $n$ points using a sequence of $\frac{n}{2}$ snaps....
n = int(input()) d = {} f = {} a = [] for i in range(n): x = [p for p in input().split()] l = [] for j in range(3): l.append(int(x[j])) a.append(l) d["*".join(x)] = i + 1 a.sort() i = 0 for k in range(0, n // 2): for i in range(0, len(a) - 1): flag = 0 ymin = min(a[i + 1]...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR DICT ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL STRING VAR BIN_OP VAR NUMBER EXPR ...
This is an easier version of the problem. In this version, $n \le 2000$. There are $n$ distinct points in three-dimensional space numbered from $1$ to $n$. The $i$-th point has coordinates $(x_i, y_i, z_i)$. The number of points $n$ is even. You'd like to remove all $n$ points using a sequence of $\frac{n}{2}$ snaps....
from sys import setrecursionlimit, stdin setrecursionlimit(10**7) def iin(): return int(stdin.readline()) def lin(): return list(map(int, stdin.readline().split())) def main(): n = iin() point = [(lin() + [i + 1]) for i in range(n)] point.sort(reverse=True) p1 = [] while point: ...
EXPR FUNC_CALL VAR BIN_OP NUMBER NUMBER FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR LIST BIN_OP VAR NUMBER VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST WHILE VAR A...
This is an easier version of the problem. In this version, $n \le 2000$. There are $n$ distinct points in three-dimensional space numbered from $1$ to $n$. The $i$-th point has coordinates $(x_i, y_i, z_i)$. The number of points $n$ is even. You'd like to remove all $n$ points using a sequence of $\frac{n}{2}$ snaps....
import sys reader = (s.rstrip() for s in sys.stdin) input = reader.__next__ n = int(input()) points = [] for i in range(n): x, y, z = map(int, input().split()) points.append((x, y, z, i + 1)) points.sort() ans = [] for i in range(n - 1): if ( points[i] and points[i][0] == points[i + 1][0] ...
IMPORT ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER...
This is an easier version of the problem. In this version, $n \le 2000$. There are $n$ distinct points in three-dimensional space numbered from $1$ to $n$. The $i$-th point has coordinates $(x_i, y_i, z_i)$. The number of points $n$ is even. You'd like to remove all $n$ points using a sequence of $\frac{n}{2}$ snaps....
import sys input = sys.stdin.buffer.readline def dis(xx, yy): val = abs(xx[0] - yy[0]) + abs(xx[1] - yy[1]) + abs(xx[2] - yy[2]) return val n = int(input()) ar = [] for i in range(n): ar.append(list(map(int, input().split()))) se = set({}) for i in range(n): if not i in se: se.add(i) ...
IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL ...
This is an easier version of the problem. In this version, $n \le 2000$. There are $n$ distinct points in three-dimensional space numbered from $1$ to $n$. The $i$-th point has coordinates $(x_i, y_i, z_i)$. The number of points $n$ is even. You'd like to remove all $n$ points using a sequence of $\frac{n}{2}$ snaps....
import sys input = sys.stdin.readline INF = float("inf") def compress(array): array2 = sorted(set(array)) memo = {value: index for index, value in enumerate(array2)} for i in range(len(array)): array[i] = memo[array[i]] return array def distance(a, b): ax, ay, az = a bx, by, bz = b ...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR STRING FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_...
This is an easier version of the problem. In this version, $n \le 2000$. There are $n$ distinct points in three-dimensional space numbered from $1$ to $n$. The $i$-th point has coordinates $(x_i, y_i, z_i)$. The number of points $n$ is even. You'd like to remove all $n$ points using a sequence of $\frac{n}{2}$ snaps....
n = int(input()) d = {} c = 1 while n: n -= 1 l = tuple(map(int, input().split())) d[c] = l c += 1 for i in d: if d[i] != -1: ans = 1e18 k = [-1, -1] x1 = d[i][0] y1 = d[i][1] z1 = d[i][2] for j in d: if d[j] != -1 and i != j: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR NUMBER WHILE VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR NUMBER FOR VAR VAR IF VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST NUMBER NUMBER ASSIGN VAR VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER...
This is an easier version of the problem. In this version, $n \le 2000$. There are $n$ distinct points in three-dimensional space numbered from $1$ to $n$. The $i$-th point has coordinates $(x_i, y_i, z_i)$. The number of points $n$ is even. You'd like to remove all $n$ points using a sequence of $\frac{n}{2}$ snaps....
n = int(input()) points = [] for i in range(n): points.append(list(map(int, input().split()))) selected = {} ans = [] j = 0 k = 0 while len(selected) != n: if j not in selected: first = points[j] else: j += 1 continue if k not in selected and k != j: second = points[k] ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE FUNC_CALL VAR VAR VAR IF VAR VAR ASSIGN VAR VAR VAR VAR NUMBER IF VAR VAR VAR VAR ASSIGN V...
This is an easier version of the problem. In this version, $n \le 2000$. There are $n$ distinct points in three-dimensional space numbered from $1$ to $n$. The $i$-th point has coordinates $(x_i, y_i, z_i)$. The number of points $n$ is even. You'd like to remove all $n$ points using a sequence of $\frac{n}{2}$ snaps....
n = int(input()) coord = [] for i in range(n): coord.append(tuple(list(map(int, input().split())) + [i + 1])) coord.sort() def odind(l): l.sort() for i in range(len(l) // 2): print(l[2 * i][-1], l[2 * i + 1][-1]) if len(l) % 2 == 0: return [] return l[-1] def dvad(l): cx = {}...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR LIST BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_DEF EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR ...
This is an easier version of the problem. In this version, $n \le 2000$. There are $n$ distinct points in three-dimensional space numbered from $1$ to $n$. The $i$-th point has coordinates $(x_i, y_i, z_i)$. The number of points $n$ is even. You'd like to remove all $n$ points using a sequence of $\frac{n}{2}$ snaps....
n = int(input()) arr = [] for i in range(n): x, y, z = map(int, input().split(" ")) arr.append([x, y, z, i + 1]) v = set() inf = 10**18 res = [] for i in range(n): if arr[i][3] not in v: curr = inf for j in range(i + 1, n): if arr[j][3] not in v: d = ( ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR LIST VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER ...
This is an easier version of the problem. In this version, $n \le 2000$. There are $n$ distinct points in three-dimensional space numbered from $1$ to $n$. The $i$-th point has coordinates $(x_i, y_i, z_i)$. The number of points $n$ is even. You'd like to remove all $n$ points using a sequence of $\frac{n}{2}$ snaps....
n = int(input()) points = [] for i in range(n): x, y, z = map(int, input().split()) points.append((x, y, z, i + 1)) points.sort() x_points = {} for p in points: x, y, z, i = p if x in x_points: x_points[x].append(p) else: x_points[x] = [p] x_to_remove = [] for x, pp in x_points.items...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR DICT FOR VAR VAR ASSIGN VAR VAR VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR LI...
This is an easier version of the problem. In this version, $n \le 2000$. There are $n$ distinct points in three-dimensional space numbered from $1$ to $n$. The $i$-th point has coordinates $(x_i, y_i, z_i)$. The number of points $n$ is even. You'd like to remove all $n$ points using a sequence of $\frac{n}{2}$ snaps....
n = int(input()) x = [] y = [] z = [] for i in range(n): X, Y, Z = map(int, input().split()) x.append(X) y.append(Y) z.append(Z) remove = 0 Re = [] for i in range(2001): Re.append(0) ad = 2 * 3 * 10**8 + 1 for i in range(n): dis = ad if Re[i] == 0: for j in range(i + 1, n): ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL...
This is an easier version of the problem. In this version, $n \le 2000$. There are $n$ distinct points in three-dimensional space numbered from $1$ to $n$. The $i$-th point has coordinates $(x_i, y_i, z_i)$. The number of points $n$ is even. You'd like to remove all $n$ points using a sequence of $\frac{n}{2}$ snaps....
def dist(p1, p2): return ( (p1[0] - p2[0]) * (p1[0] - p2[0]) + (p1[1] - p2[1]) * (p1[1] - p2[1]) + (p1[2] - p2[2]) * (p1[2] - p2[2]) ) n = int(input()) seq = set([tuple([int(c) for c in input().split()] + [i]) for i in range(n)]) while seq: p1 = seq.pop() mn = float("infinity")...
FUNC_DEF RETURN BIN_OP BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER BIN_OP BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER BIN_OP BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP FUNC_CALL ...
This is an easier version of the problem. In this version, $n \le 2000$. There are $n$ distinct points in three-dimensional space numbered from $1$ to $n$. The $i$-th point has coordinates $(x_i, y_i, z_i)$. The number of points $n$ is even. You'd like to remove all $n$ points using a sequence of $\frac{n}{2}$ snaps....
import sys input = lambda: sys.stdin.readline().rstrip() N = int(input()) D = {} ans = [] for i in range(N): x, y, z = map(int, input().split()) if z in D: if y in D[z]: D[z][y].append((x, i)) else: D[z][y] = [(x, i)] else: D[z] = {y: [(x, i)]} E = {} for z i...
IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR IF VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR LIST VAR VAR ASSIGN VAR VAR DICT VAR LIS...
This is an easier version of the problem. In this version, $n \le 2000$. There are $n$ distinct points in three-dimensional space numbered from $1$ to $n$. The $i$-th point has coordinates $(x_i, y_i, z_i)$. The number of points $n$ is even. You'd like to remove all $n$ points using a sequence of $\frac{n}{2}$ snaps....
from sys import stdin def input(): return stdin.readline()[:-1] def intput(): return int(input()) def sinput(): return input().split() def intsput(): return list(map(int, sinput())) def solve1d(points): points.sort() rem = False if len(points) % 2: rem = points.pop() re...
FUNC_DEF RETURN FUNC_CALL VAR NUMBER FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_DEF EXPR FUNC_CALL VAR ASSIGN VAR NUMBER IF BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR RETURN LIST VAR VAR FUNC_DEF AS...
This is an easier version of the problem. In this version, $n \le 2000$. There are $n$ distinct points in three-dimensional space numbered from $1$ to $n$. The $i$-th point has coordinates $(x_i, y_i, z_i)$. The number of points $n$ is even. You'd like to remove all $n$ points using a sequence of $\frac{n}{2}$ snaps....
def main(): n = int(input()) lkz = {} lky = {} for i in range(n): px, py, pz = map(int, input().split()) if pz not in lkz: lkz[pz] = set() lkz[pz].add(py) lky[pz, py] = [(pz, py, px, i + 1)] else: lkz[pz].add(py) if (pz,...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR VAR LIST VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR IF VA...
This is an easier version of the problem. In this version, $n \le 2000$. There are $n$ distinct points in three-dimensional space numbered from $1$ to $n$. The $i$-th point has coordinates $(x_i, y_i, z_i)$. The number of points $n$ is even. You'd like to remove all $n$ points using a sequence of $\frac{n}{2}$ snaps....
import sys input = sys.stdin.buffer.readline con = 10**9 + 7 INF = float("inf") def getlist(): return list(map(int, input().split())) def main(): N = int(input()) n = N // 2 node = [] for i in range(N): x, y, z = getlist() node.append([x, y, z, i]) for i in range(n - 1): ...
IMPORT ASSIGN VAR VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR STRING FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL ...