output_description
stringlengths
15
956
submission_id
stringlengths
10
10
status
stringclasses
3 values
problem_id
stringlengths
6
6
input_description
stringlengths
9
2.55k
attempt
stringlengths
1
13.7k
problem_description
stringlengths
7
5.24k
samples
stringlengths
2
2.72k
Print one longest string that is a subsequence of both s and t. If there are multiple such strings, any of them will be accepted. * * *
s339359819
Runtime Error
p03165
Input is given from Standard Input in the following format: s t
a = list(map(input())) b = list(map(input())) k = max(len(a),len(b)) dp = [['']*(len(b)+1) for i in range(len(a))] for i in range(len(a)): for j in range(len(b)): if a[i] == b[j]: dp[i+1][j+1] = dp[i][j] + 1 else: dp[i+1][j+1] = max(dp[i+1][j],dp[i][j+1]) global ans = "" def rec(m,n): if m == 0 and n == 0: return ans if a[m-1] == b[n-1]: ans += a[m] rec(m-1.n-1) elif dp[m-1][n] > dp[m][n-1]: rec(m-1,n) else: rec(m,n-1) rec(len(a),len(b)) print(ans)
Statement You are given strings s and t. Find one longest string that is a subsequence of both s and t.
[{"input": "axyb\n abyxb", "output": "axb\n \n\nThe answer is `axb` or `ayb`; either will be accepted.\n\n* * *"}, {"input": "aa\n xayaz", "output": "aa\n \n\n* * *"}, {"input": "a\n z", "output": "The answer is `` (an empty string).\n\n* * *"}, {"input": "abracadabra\n avadakedavra", "output": "aaadara"}]
Print one longest string that is a subsequence of both s and t. If there are multiple such strings, any of them will be accepted. * * *
s437345832
Runtime Error
p03165
Input is given from Standard Input in the following format: s t
S=input() T=input() s=len(S) t=len(T)) dp=[['' for i in range(T+1)] for j in range(T+1)] for i in range(S): for j in range(T): if s[i]==t[j]: dp[i+1][j+1]=dp[i][j]+s[i] else: dp[i+1][j+1]=dp[i+1][j] if len(dp[i][j+1])>len(dp[i+1][j]): dp[i+1][j+1]=dp[i][j+1] print(dp[S][T])
Statement You are given strings s and t. Find one longest string that is a subsequence of both s and t.
[{"input": "axyb\n abyxb", "output": "axb\n \n\nThe answer is `axb` or `ayb`; either will be accepted.\n\n* * *"}, {"input": "aa\n xayaz", "output": "aa\n \n\n* * *"}, {"input": "a\n z", "output": "The answer is `` (an empty string).\n\n* * *"}, {"input": "abracadabra\n avadakedavra", "output": "aaadara"}]
Print one longest string that is a subsequence of both s and t. If there are multiple such strings, any of them will be accepted. * * *
s261349972
Runtime Error
p03165
Input is given from Standard Input in the following format: s t
s=input() t=input() n=len(s) m=len(t) dp=[[0 for i in range(m+1)] for j in range(n+1)] ​ ​ #メイン ​ #dp[i][j]:=s_1~s_iとt_1~t_jに対するLCSの長さ for i in range(n): for j in range(m): if s[i]==t[j]: dp[i+1][j+1]=dp[i][j]+1 #同じならくっつけられる else: dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j]) #print(dp[n][m]) #dpを逆からたどって文字列を復元 ans = '' while(dp[n][m]>0): if dp[n][m] == dp[n-1][m-1] +1 and dp[n][m] == dp[n-1][m] +1 and dp[n][m] == dp[n][m-1] +1: ans += s[n-1] n -= 1 m -= 1 elif dp[n-1][m] > dp[n][m-1]: n -= 1 else: m -= 1 print(''.join(reversed(list(ans))))
Statement You are given strings s and t. Find one longest string that is a subsequence of both s and t.
[{"input": "axyb\n abyxb", "output": "axb\n \n\nThe answer is `axb` or `ayb`; either will be accepted.\n\n* * *"}, {"input": "aa\n xayaz", "output": "aa\n \n\n* * *"}, {"input": "a\n z", "output": "The answer is `` (an empty string).\n\n* * *"}, {"input": "abracadabra\n avadakedavra", "output": "aaadara"}]
Print one longest string that is a subsequence of both s and t. If there are multiple such strings, any of them will be accepted. * * *
s639470777
Runtime Error
p03165
Input is given from Standard Input in the following format: s t
from numba import njit S = input() T = input() dp = [[ "" for _ in range(len(S) + 1 )] for _ in range(len(T) + 1)] @njit def solv() for i in range(1,len(dp)): for j in range(1,len(dp[0])): if T[i - 1] == S[j-1]: dp[i ][j ] = dp[i-1][j-1] + S[j-1] else: res1 = dp[i - 1][j] res2 = dp[i][j - 1] l1 = len(res1) l2 = len(res2) if l1 > l2: dp[i ][j] = res1 else: dp[i ][j] = res2 solv() print(dp[-1][-1])
Statement You are given strings s and t. Find one longest string that is a subsequence of both s and t.
[{"input": "axyb\n abyxb", "output": "axb\n \n\nThe answer is `axb` or `ayb`; either will be accepted.\n\n* * *"}, {"input": "aa\n xayaz", "output": "aa\n \n\n* * *"}, {"input": "a\n z", "output": "The answer is `` (an empty string).\n\n* * *"}, {"input": "abracadabra\n avadakedavra", "output": "aaadara"}]
Print one longest string that is a subsequence of both s and t. If there are multiple such strings, any of them will be accepted. * * *
s893819791
Runtime Error
p03165
Input is given from Standard Input in the following format: s t
import sys def main(): S=list(sys.stdin.readline())[:-1] T=list(sys.stdin.readline())[:-1] lS=len(S) lT=len(T) dp=[[0]*lS for _ in range(lT)] for iT in range(lT): for iS in range(lS): if S[iS]==T[iT]: if iS-1>=0 and iT-1>=0: dp[iT][iS] = dp[iT-1][iS-1]+1 else: dp[iT][iS] = 1 else: if iS-1>=0 and (iT-1<0 or dp[iT][iS-1]>=dp[iT-1][iS]): dp[iT][iS] = dp[iT][iS-1] elif iT-1>=0 and (iS-1<0 or dp[iT-1][iS]>=dp[iT][iS-1]): dp[iT][iS] = dp[iT-1][iS] iS = lS-1 iT = lT-1 ans = "" while(iS>0 and iT>0): if dp[iT][iS]==dp[iT-1][iS-1]: iS -= 1 iT -= 1 elif dp[iT][iS]==dp[iT][iS-1]: iS -= 1 else: ans = S[iS]+ans iS -= 1 iT -= 1 if dp[iT][iS]=1: if iS == 0: ans = S[0]+ans else: ans = T[0]+ans print(ans) if __name__ == '__main__': main()
Statement You are given strings s and t. Find one longest string that is a subsequence of both s and t.
[{"input": "axyb\n abyxb", "output": "axb\n \n\nThe answer is `axb` or `ayb`; either will be accepted.\n\n* * *"}, {"input": "aa\n xayaz", "output": "aa\n \n\n* * *"}, {"input": "a\n z", "output": "The answer is `` (an empty string).\n\n* * *"}, {"input": "abracadabra\n avadakedavra", "output": "aaadara"}]
Print one longest string that is a subsequence of both s and t. If there are multiple such strings, any of them will be accepted. * * *
s570704807
Runtime Error
p03165
Input is given from Standard Input in the following format: s t
import java.util.*; public class Main{ public static void main(String args[]){ Scanner in = new Scanner(System.in); String s = in.next(); String t = in.next(); int n = s.length(); int m = t.length(); String dp[][] = new String[n+1][m+1]; in.close(); for(int i=0;i<=n;i++){ dp[i][0] = ""; } for(int j=0;j<=m;j++){ dp[0][j] = ""; } for(int i=0;i<n;i++){ for(int j=0;j<m;j++){ if (s.charAt(i) == t.charAt(j)){ dp[i+1][j+1] = dp[i][j]+s.charAt(i); } else{ if (dp[i][j+1].length() >= dp[i+1][j].length()){ dp[i+1][j+1] = dp[i][j+1]; } else{ dp[i+1][j+1] = dp[i+1][j]; } } } } System.out.println(dp[n][m]); } }
Statement You are given strings s and t. Find one longest string that is a subsequence of both s and t.
[{"input": "axyb\n abyxb", "output": "axb\n \n\nThe answer is `axb` or `ayb`; either will be accepted.\n\n* * *"}, {"input": "aa\n xayaz", "output": "aa\n \n\n* * *"}, {"input": "a\n z", "output": "The answer is `` (an empty string).\n\n* * *"}, {"input": "abracadabra\n avadakedavra", "output": "aaadara"}]
Print one longest string that is a subsequence of both s and t. If there are multiple such strings, any of them will be accepted. * * *
s689527859
Runtime Error
p03165
Input is given from Standard Input in the following format: s t
#!/usr/bin python3 # -*- coding: utf-8 -*- #################################################### # LCS(longest common sequence) # 部分列で最長の共通のもの #################################################### # dp[i+1][j+1]:= s の i 文字目までと t の j 文字目まででの LCS の長さ def main(): S = input() T = input() ls = len(S) lt = len(T) dp = [[0]*(lt+1) for _ in range(ls+1)] for i in range(ls): for j in range(lt): if S[i]==T[j]: dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1], dp[i][j]+1) elif: dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1]) # print(dp) # print(dp[ls][lt]) # 復元 res = '' i, j = ls, lt while (i > 0 and j > 0): # (i-1, j) -> (i, j) と更新されていた場合 if dp[i][j] == dp[i-1][j]: i-=1 # DP の遷移を遡る # (i, j-1) -> (i, j) と更新されていた場合 elif dp[i][j] == dp[i][j-1]: j-=1 # DP の遷移を遡る # (i-1, j-1) -> (i, j) と更新されていた場合 else: res = S[i-1] + res # このとき s[i-1] == t[j-1] なので、t[j-1] + res でも OK i-=1 j-=1 # DP の遷移を遡る print(res) if __name__ == '__main__': main()
Statement You are given strings s and t. Find one longest string that is a subsequence of both s and t.
[{"input": "axyb\n abyxb", "output": "axb\n \n\nThe answer is `axb` or `ayb`; either will be accepted.\n\n* * *"}, {"input": "aa\n xayaz", "output": "aa\n \n\n* * *"}, {"input": "a\n z", "output": "The answer is `` (an empty string).\n\n* * *"}, {"input": "abracadabra\n avadakedavra", "output": "aaadara"}]
Print one longest string that is a subsequence of both s and t. If there are multiple such strings, any of them will be accepted. * * *
s034244546
Wrong Answer
p03165
Input is given from Standard Input in the following format: s t
s, t = [tuple(input()) for u in (1, 1)] l, li = [["" for i in range(len(s) + 1)] for j in (1, 1)] f = 0 for j in range(len(t)): for i in range(len(s)): if f: if t[j] == s[i]: l[i + 1] = li[i] + t[j] else: l[i + 1] = li[i + 1] if len(li[i + 1]) > len(l[i]) else l[i] else: if t[j] == s[i]: li[i + 1] = l[i] + t[j] else: li[i + 1] = l[i + 1] if len(l[i + 1]) > len(li[i]) else li[i] f = (f + 1) % 2 print(li[-1] if f else l[-1])
Statement You are given strings s and t. Find one longest string that is a subsequence of both s and t.
[{"input": "axyb\n abyxb", "output": "axb\n \n\nThe answer is `axb` or `ayb`; either will be accepted.\n\n* * *"}, {"input": "aa\n xayaz", "output": "aa\n \n\n* * *"}, {"input": "a\n z", "output": "The answer is `` (an empty string).\n\n* * *"}, {"input": "abracadabra\n avadakedavra", "output": "aaadara"}]
Print one longest string that is a subsequence of both s and t. If there are multiple such strings, any of them will be accepted. * * *
s985664966
Wrong Answer
p03165
Input is given from Standard Input in the following format: s t
import numpy as np s = np.array([i for i in input()]) t = np.array([i for i in input()]) num_s = int(s.shape[0]) num_t = int(t.shape[0]) dp = np.zeros((num_s + 1, num_t + 1), dtype="int64") eq = s[:, None] == t[None, :] print(len(eq[0])) for i in range(num_s): np.maximum(dp[i, 1:], dp[i, :-1] + eq[i], out=dp[i + 1, 1:]) np.maximum.accumulate(dp[i + 1], out=dp[i + 1]) # print(dp) res = "" pos_s = num_s pos_t = num_t while len(res) < np.max(dp): temp = dp[pos_s, pos_t] # print(temp) if dp[pos_s - 1, pos_t] == temp: pos_s -= 1 if dp[pos_s, pos_t - 1] == temp: pos_t -= 1 if dp[pos_s - 1, pos_t - 1] != temp: res += s[pos_s - 1] pos_s -= 1 pos_t -= 1 # print(res, pos_s-1) print(res[::-1])
Statement You are given strings s and t. Find one longest string that is a subsequence of both s and t.
[{"input": "axyb\n abyxb", "output": "axb\n \n\nThe answer is `axb` or `ayb`; either will be accepted.\n\n* * *"}, {"input": "aa\n xayaz", "output": "aa\n \n\n* * *"}, {"input": "a\n z", "output": "The answer is `` (an empty string).\n\n* * *"}, {"input": "abracadabra\n avadakedavra", "output": "aaadara"}]
Print one longest string that is a subsequence of both s and t. If there are multiple such strings, any of them will be accepted. * * *
s239679386
Wrong Answer
p03165
Input is given from Standard Input in the following format: s t
def solve(s, t): # 1-origin s_size, t_size = len(s), len(t) dp = [[0] * (t_size + 1) for _ in range(s_size + 1)] for i in range(1, s_size + 1): for j in range(1, t_size + 1): prev_i, prev_j = i - 1, j - 1 dp[i][j] = max(dp[prev_i][j], dp[i][prev_j]) if s[prev_i] != t[prev_j]: # 不一致 continue if dp[prev_i][prev_j] + 1 <= dp[i][j]: # maxを超えないとき continue dp[i][j] = dp[prev_i][prev_j] + 1 # 文字復元 buff = [] min_length = 0 for key in range(t_size + 1): if min_length < dp[s_size][key]: min_length = dp[s_size][key] buff.append(t[key - 1]) return "".join(buff) def main(): s, t = input(), input() ans = solve(s, t) print(ans) main()
Statement You are given strings s and t. Find one longest string that is a subsequence of both s and t.
[{"input": "axyb\n abyxb", "output": "axb\n \n\nThe answer is `axb` or `ayb`; either will be accepted.\n\n* * *"}, {"input": "aa\n xayaz", "output": "aa\n \n\n* * *"}, {"input": "a\n z", "output": "The answer is `` (an empty string).\n\n* * *"}, {"input": "abracadabra\n avadakedavra", "output": "aaadara"}]
Print one longest string that is a subsequence of both s and t. If there are multiple such strings, any of them will be accepted. * * *
s617441829
Wrong Answer
p03165
Input is given from Standard Input in the following format: s t
# -*- coding: utf-8 -*- import numpy as np EDPC = "https://atcoder.jp/contests/DP/" TDPC = "https://atcoder.jp/contests/tdpc/tasks" ### TESTCASE test = "" # test = \ """ axyb abyxb ans axb ans ayb """ ############ test = list(reversed(test.strip().splitlines())) if test: def input2(): return test.pop() else: def input2(): return input() ####### MAIN s = input2() t = input2() sn = len(s) tn = len(t) sv = np.array(["A"] + list(s)) tv = np.array(["B"] + list(t)) dp = np.zeros((sn + 1, tn + 1), dtype="int") # fill dp table for si in range(sn): flag = np.array(sv[si + 1] == tv, dtype="int") flag2 = np.array(np.add.accumulate(flag) > 0, dtype="int") tmp = dp[si] + flag tmp2 = dp[si] + flag2 if (tmp == np.sort(tmp)).all(): dp[si + 1] = tmp else: dp[si + 1] = tmp2 # get ans sequence ans = "" si, ti = sn, tn while si: while dp[si][ti] == dp[si][ti - 1] and ti: ti -= 1 if dp[si][ti] > dp[si - 1][ti]: ans += t[ti - 1] si -= 1 # output ans print(ans[::-1])
Statement You are given strings s and t. Find one longest string that is a subsequence of both s and t.
[{"input": "axyb\n abyxb", "output": "axb\n \n\nThe answer is `axb` or `ayb`; either will be accepted.\n\n* * *"}, {"input": "aa\n xayaz", "output": "aa\n \n\n* * *"}, {"input": "a\n z", "output": "The answer is `` (an empty string).\n\n* * *"}, {"input": "abracadabra\n avadakedavra", "output": "aaadara"}]
Print the maximum possible value of s. * * *
s747392770
Wrong Answer
p03535
Input is given from Standard Input in the following format: N D_1 D_2 ... D_N
import collections n = int(input()) inp_list = list(map(int, input().split())) inp_list.append(0) c = collections.Counter(inp_list) a = c.most_common() def ura(time): if time == 12: time = 12 elif time == 0: time = 0 else: time = 24 - time return time member = [] for tup in a: if tup[1] > 1: member.append(tup[0]) member.append(tup[0]) elif tup[1] == 1: member.append(tup[0]) ans = 0 for i in range(2 ** len(member)): trry = format(i, "0" + str(len(member)) + "b") time_diff = 24 for ii in range(len(member) - 1): for iii in range(ii + 1, len(member)): A = member[ii] if trry[iii] == "0": B = member[iii] else: B = ura(member[iii]) a_b = abs(A - B) b_a = min(A, B) + 24 - max(A, B) time_diff = min(time_diff, a_b, b_a) ans = max(ans, time_diff) print(ans)
Statement In CODE FESTIVAL XXXX, there are N+1 participants from all over the world, including Takahashi. Takahashi checked and found that the _time gap_ (defined below) between the local times in his city and the i-th person's city was D_i hours. The time gap between two cities is defined as follows. For two cities A and B, if the local time in city B is d o'clock at the moment when the local time in city A is 0 o'clock, then the time gap between these two cities is defined to be min(d,24-d) hours. Here, we are using 24-hour notation. That is, the local time in the i-th person's city is either d o'clock or 24-d o'clock at the moment when the local time in Takahashi's city is 0 o'clock, for example. Then, for each pair of two people chosen from the N+1 people, he wrote out the time gap between their cities. Let the smallest time gap among them be s hours. Find the maximum possible value of s.
[{"input": "3\n 7 12 8", "output": "4\n \n\nFor example, consider the situation where it is 7, 12 and 16 o'clock in each\nperson's city at the moment when it is 0 o'clock in Takahashi's city. In this\ncase, the time gap between the second and third persons' cities is 4 hours.\n\n* * *"}, {"input": "2\n 11 11", "output": "2\n \n\n* * *"}, {"input": "1\n 0", "output": "0\n \n\nNote that Takahashi himself is also a participant."}]
Print the maximum possible value of s. * * *
s711636756
Wrong Answer
p03535
Input is given from Standard Input in the following format: N D_1 D_2 ... D_N
def i1(): return int(input()) def i2(): return [int(i) for i in input().split()] n = i1() d = i2() e = [[d[0], 24 - d[0]]] ccc = 100 for i in range(1, n): cc = [] for j in [d[i], 24 - d[i]]: c = 100 for k in e: c = min(c, max(abs(j - k[0]), abs(j - k[1]))) cc.append(c) ccc = min(ccc, max(cc)) e.append([d[i], 24 - d[i]]) if ccc == 100: print(min(d[0], 24 - d[0])) else: print(ccc)
Statement In CODE FESTIVAL XXXX, there are N+1 participants from all over the world, including Takahashi. Takahashi checked and found that the _time gap_ (defined below) between the local times in his city and the i-th person's city was D_i hours. The time gap between two cities is defined as follows. For two cities A and B, if the local time in city B is d o'clock at the moment when the local time in city A is 0 o'clock, then the time gap between these two cities is defined to be min(d,24-d) hours. Here, we are using 24-hour notation. That is, the local time in the i-th person's city is either d o'clock or 24-d o'clock at the moment when the local time in Takahashi's city is 0 o'clock, for example. Then, for each pair of two people chosen from the N+1 people, he wrote out the time gap between their cities. Let the smallest time gap among them be s hours. Find the maximum possible value of s.
[{"input": "3\n 7 12 8", "output": "4\n \n\nFor example, consider the situation where it is 7, 12 and 16 o'clock in each\nperson's city at the moment when it is 0 o'clock in Takahashi's city. In this\ncase, the time gap between the second and third persons' cities is 4 hours.\n\n* * *"}, {"input": "2\n 11 11", "output": "2\n \n\n* * *"}, {"input": "1\n 0", "output": "0\n \n\nNote that Takahashi himself is also a participant."}]
Print the maximum possible value of s. * * *
s347084186
Wrong Answer
p03535
Input is given from Standard Input in the following format: N D_1 D_2 ... D_N
N = int(input()) + 1 D = [0] + [int(i) for i in input().split()] ans = 12 for i in D: for j in D: x = [i, 24 - i] y = [j, 24 - j] for p in x: for q in y: if ans > min(abs(p - q), 24 - abs(p - q)): ans = min(abs(p - q), 24 - abs(p - q)) print(ans)
Statement In CODE FESTIVAL XXXX, there are N+1 participants from all over the world, including Takahashi. Takahashi checked and found that the _time gap_ (defined below) between the local times in his city and the i-th person's city was D_i hours. The time gap between two cities is defined as follows. For two cities A and B, if the local time in city B is d o'clock at the moment when the local time in city A is 0 o'clock, then the time gap between these two cities is defined to be min(d,24-d) hours. Here, we are using 24-hour notation. That is, the local time in the i-th person's city is either d o'clock or 24-d o'clock at the moment when the local time in Takahashi's city is 0 o'clock, for example. Then, for each pair of two people chosen from the N+1 people, he wrote out the time gap between their cities. Let the smallest time gap among them be s hours. Find the maximum possible value of s.
[{"input": "3\n 7 12 8", "output": "4\n \n\nFor example, consider the situation where it is 7, 12 and 16 o'clock in each\nperson's city at the moment when it is 0 o'clock in Takahashi's city. In this\ncase, the time gap between the second and third persons' cities is 4 hours.\n\n* * *"}, {"input": "2\n 11 11", "output": "2\n \n\n* * *"}, {"input": "1\n 0", "output": "0\n \n\nNote that Takahashi himself is also a participant."}]
Print the maximum possible value of s. * * *
s565096689
Wrong Answer
p03535
Input is given from Standard Input in the following format: N D_1 D_2 ... D_N
from collections import defaultdict, deque import sys, heapq, bisect, math, itertools, string, queue, datetime sys.setrecursionlimit(10**8) INF = float("inf") mod = 10**9 + 7 def inpl(): return list(map(int, input().split())) def inpls(): return list(input().split()) N = int(input()) dd = inpl() cnt = [0] * 13 for d in dd: cnt[d] += 1 koho = [0] ed1 = [] for d, n in enumerate(cnt): if n >= 3: print(0) sys.exit() elif n == 2: koho.append(d) koho.append(24 - d) elif n == 1: ed1.append(d) L = len(ed1) ans = 0 if L != 0: for bit in range((1 << L) - 1): tmp = koho[:] for b in range(L): if bit & (1 << b): tmp.append(ed1[b]) else: tmp.append(24 - ed1[b]) tmp.sort() azusa = INF azunyan = len(tmp) for x in range(1, azunyan): azusa = min(tmp[x] - tmp[x - 1], azusa) ans = max(azusa, ans) else: tmp = koho[:] azunyan = len(tmp) ans = INF for x in range(1, azunyan): ans = min(tmp[x] - tmp[x - 1], ans) if ans == 24: print(0) else: print(ans)
Statement In CODE FESTIVAL XXXX, there are N+1 participants from all over the world, including Takahashi. Takahashi checked and found that the _time gap_ (defined below) between the local times in his city and the i-th person's city was D_i hours. The time gap between two cities is defined as follows. For two cities A and B, if the local time in city B is d o'clock at the moment when the local time in city A is 0 o'clock, then the time gap between these two cities is defined to be min(d,24-d) hours. Here, we are using 24-hour notation. That is, the local time in the i-th person's city is either d o'clock or 24-d o'clock at the moment when the local time in Takahashi's city is 0 o'clock, for example. Then, for each pair of two people chosen from the N+1 people, he wrote out the time gap between their cities. Let the smallest time gap among them be s hours. Find the maximum possible value of s.
[{"input": "3\n 7 12 8", "output": "4\n \n\nFor example, consider the situation where it is 7, 12 and 16 o'clock in each\nperson's city at the moment when it is 0 o'clock in Takahashi's city. In this\ncase, the time gap between the second and third persons' cities is 4 hours.\n\n* * *"}, {"input": "2\n 11 11", "output": "2\n \n\n* * *"}, {"input": "1\n 0", "output": "0\n \n\nNote that Takahashi himself is also a participant."}]
Print the maximum possible value of s. * * *
s265156212
Wrong Answer
p03535
Input is given from Standard Input in the following format: N D_1 D_2 ... D_N
n = int(input()) ds = list(map(int, input().split())) ans = 0 for i in range(n): mx = 1000 for j in range(n): if i != j: if ds[i] == ds[j]: mx = min(mx, abs(ds[i] - (24 - ds[j]))) else: mx = min(mx, abs(ds[i] - ds[j]), abs(ds[i] - (24 - ds[j]))) ans = max(ans, mx) print(ans if n > 1 else 0)
Statement In CODE FESTIVAL XXXX, there are N+1 participants from all over the world, including Takahashi. Takahashi checked and found that the _time gap_ (defined below) between the local times in his city and the i-th person's city was D_i hours. The time gap between two cities is defined as follows. For two cities A and B, if the local time in city B is d o'clock at the moment when the local time in city A is 0 o'clock, then the time gap between these two cities is defined to be min(d,24-d) hours. Here, we are using 24-hour notation. That is, the local time in the i-th person's city is either d o'clock or 24-d o'clock at the moment when the local time in Takahashi's city is 0 o'clock, for example. Then, for each pair of two people chosen from the N+1 people, he wrote out the time gap between their cities. Let the smallest time gap among them be s hours. Find the maximum possible value of s.
[{"input": "3\n 7 12 8", "output": "4\n \n\nFor example, consider the situation where it is 7, 12 and 16 o'clock in each\nperson's city at the moment when it is 0 o'clock in Takahashi's city. In this\ncase, the time gap between the second and third persons' cities is 4 hours.\n\n* * *"}, {"input": "2\n 11 11", "output": "2\n \n\n* * *"}, {"input": "1\n 0", "output": "0\n \n\nNote that Takahashi himself is also a participant."}]
Print the maximum possible value of s. * * *
s002708213
Accepted
p03535
Input is given from Standard Input in the following format: N D_1 D_2 ... D_N
n = int(input()) t = [0] * 24 t[0] = 1 a = 1 for i in sorted(list(map(int, input().split()))): t[a * i] += 1 a *= -1 for i in t: if i > 1: print(0) break else: m = 24 c = 1 t += [1] for i in t[1:]: if i == 1: if m > c: m = c c = 1 else: c += 1 print(m)
Statement In CODE FESTIVAL XXXX, there are N+1 participants from all over the world, including Takahashi. Takahashi checked and found that the _time gap_ (defined below) between the local times in his city and the i-th person's city was D_i hours. The time gap between two cities is defined as follows. For two cities A and B, if the local time in city B is d o'clock at the moment when the local time in city A is 0 o'clock, then the time gap between these two cities is defined to be min(d,24-d) hours. Here, we are using 24-hour notation. That is, the local time in the i-th person's city is either d o'clock or 24-d o'clock at the moment when the local time in Takahashi's city is 0 o'clock, for example. Then, for each pair of two people chosen from the N+1 people, he wrote out the time gap between their cities. Let the smallest time gap among them be s hours. Find the maximum possible value of s.
[{"input": "3\n 7 12 8", "output": "4\n \n\nFor example, consider the situation where it is 7, 12 and 16 o'clock in each\nperson's city at the moment when it is 0 o'clock in Takahashi's city. In this\ncase, the time gap between the second and third persons' cities is 4 hours.\n\n* * *"}, {"input": "2\n 11 11", "output": "2\n \n\n* * *"}, {"input": "1\n 0", "output": "0\n \n\nNote that Takahashi himself is also a participant."}]
Print the answer. * * *
s325535434
Runtime Error
p02774
Input is given from Standard Input in the following format: N K A_1 A_2 \dots A_N
a = input().split() a, b = map(int, a) c = list(input().split()) c = list(map(int, c)) e = [] for i in range(b): for l in range(b): if i < l: if l < a: product = c[i] * c[l] e.append(product) e.sort() print(e[b - 1])
Statement We have N integers A_1, A_2, ..., A_N. There are \frac{N(N-1)}{2} ways to choose two of them and form a pair. If we compute the product of each of those pairs and sort the results in ascending order, what will be the K-th number in that list?
[{"input": "4 3\n 3 3 -4 -2", "output": "-6\n \n\nThere are six ways to form a pair. The products of those pairs are 9, -12, -6,\n-12, -6, 8.\n\nSorting those numbers in ascending order, we have -12, -12, -6, -6, 8, 9. The\nthird number in this list is -6.\n\n* * *"}, {"input": "10 40\n 5 4 3 2 -1 0 0 0 0 0", "output": "6\n \n\n* * *"}, {"input": "30 413\n -170202098 -268409015 537203564 983211703 21608710 -443999067 -937727165 -97596546 -372334013 398994917 -972141167 798607104 -949068442 -959948616 37909651 0 886627544 -20098238 0 -948955241 0 -214720580 277222296 -18897162 834475626 0 -425610555 110117526 663621752 0", "output": "448283280358331064"}]
Print the answer. * * *
s828787099
Runtime Error
p02774
Input is given from Standard Input in the following format: N K A_1 A_2 \dots A_N
import numpy as np def numpy_combinations(arr): r, c = np.triu_indices(len(arr), 1) # return np.array(r*c) return np.stack((arr[r], arr[c]), 1) def solve(N, K, S): arr = np.array(S, dtype=np.int64) arr = numpy_combinations(arr) arr = np.prod(arr, axis=1) arr = np.sort(arr) print(arr[K - 1]) def main(): N, K = map(int, input().split()) S = [int(x) for x in input().split()] solve(N, K, S) if __name__ == "__main__": main()
Statement We have N integers A_1, A_2, ..., A_N. There are \frac{N(N-1)}{2} ways to choose two of them and form a pair. If we compute the product of each of those pairs and sort the results in ascending order, what will be the K-th number in that list?
[{"input": "4 3\n 3 3 -4 -2", "output": "-6\n \n\nThere are six ways to form a pair. The products of those pairs are 9, -12, -6,\n-12, -6, 8.\n\nSorting those numbers in ascending order, we have -12, -12, -6, -6, 8, 9. The\nthird number in this list is -6.\n\n* * *"}, {"input": "10 40\n 5 4 3 2 -1 0 0 0 0 0", "output": "6\n \n\n* * *"}, {"input": "30 413\n -170202098 -268409015 537203564 983211703 21608710 -443999067 -937727165 -97596546 -372334013 398994917 -972141167 798607104 -949068442 -959948616 37909651 0 886627544 -20098238 0 -948955241 0 -214720580 277222296 -18897162 834475626 0 -425610555 110117526 663621752 0", "output": "448283280358331064"}]
Print the answer. * * *
s045183707
Runtime Error
p02774
Input is given from Standard Input in the following format: N K A_1 A_2 \dots A_N
data1 = [int(x) for x in input().split()] data2 = [int(x) for x in input().split()] hu = [0, 0, 0] plus = [] minus = [] zero = [] for x in data2: if x > 0: hu[0] = hu[0] + 1 plus.append(x) elif x < 0: hu[2] = hu[2] + 1 minus.append(x) else: hu[1] = hu[1] + 1 zero.append(0) ans = [ hu[0] * (hu[0] - 1) / 2 + hu[2] * (hu[2] - 1) / 2, (hu[0] + hu[2]) * hu[1], hu[0] * hu[2], ] check = [] if ans[2] > data1[1]: for x in plus: for y in minus: check.append(x * y) check.sort() print(check[data1[1]]) elif ans[2] + ans[1] > data1[1]: print(0) else: for x in [plus, minus]: for i in range(len(x)): for j in range(i, len(x)): check.append(x[j] * x[i]) check.sort() print(check[data1[1] - ans[2] - ans[1]])
Statement We have N integers A_1, A_2, ..., A_N. There are \frac{N(N-1)}{2} ways to choose two of them and form a pair. If we compute the product of each of those pairs and sort the results in ascending order, what will be the K-th number in that list?
[{"input": "4 3\n 3 3 -4 -2", "output": "-6\n \n\nThere are six ways to form a pair. The products of those pairs are 9, -12, -6,\n-12, -6, 8.\n\nSorting those numbers in ascending order, we have -12, -12, -6, -6, 8, 9. The\nthird number in this list is -6.\n\n* * *"}, {"input": "10 40\n 5 4 3 2 -1 0 0 0 0 0", "output": "6\n \n\n* * *"}, {"input": "30 413\n -170202098 -268409015 537203564 983211703 21608710 -443999067 -937727165 -97596546 -372334013 398994917 -972141167 798607104 -949068442 -959948616 37909651 0 886627544 -20098238 0 -948955241 0 -214720580 277222296 -18897162 834475626 0 -425610555 110117526 663621752 0", "output": "448283280358331064"}]
Print the answer. * * *
s747272559
Wrong Answer
p02774
Input is given from Standard Input in the following format: N K A_1 A_2 \dots A_N
from sys import stdin import itertools def cmb(n, r): if n < 2: return 0 if n - r < r: r = n - r if r == 0: return 1 if r == 1: return n numerator = [n - r + k + 1 for k in range(r)] denominator = [k + 1 for k in range(r)] for p in range(2, r + 1): pivot = denominator[p - 1] if pivot > 1: offset = (n - r) % p for k in range(p - 1, r, p): numerator[k - offset] /= pivot denominator[k] /= pivot result = 1 for k in range(r): if numerator[k] > 1: result *= int(numerator[k]) return result if __name__ == "__main__": N, K = [int(x) for x in stdin.readline().rstrip().split()] A = [int(x) for x in stdin.readline().rstrip().split()] A = sorted(A) MINUS = [x for x in A if x < 0] ZERO = [x for x in A if x == 0] PLUS = [x for x in A if x > 0] # print(MINUS) # print(ZERO) # print(PLUS) num_minus = len(MINUS) * len(PLUS) num_zero = len(MINUS) * len(ZERO) + len(PLUS) * len(ZERO) + cmb(len(ZERO), 2) num_plus = cmb(len(PLUS), 2) + cmb(len(MINUS), 2) # print(num_minus) # print(num_zero) # print(num_plus) # print('ALL {}'.format(num_minus + num_zero + num_plus)) if K <= num_minus: counter = len(PLUS) for i, m in enumerate(MINUS): if counter < K: counter += len(PLUS) else: index = counter - K print(m * PLUS[index]) elif K <= num_minus + num_zero: print(0) else: index = K - num_minus - num_zero - 1 a = list(itertools.combinations(PLUS, 2)) + list( itertools.combinations(MINUS, 2) ) a = sorted([c[0] * c[1] for c in a]) print(a[index])
Statement We have N integers A_1, A_2, ..., A_N. There are \frac{N(N-1)}{2} ways to choose two of them and form a pair. If we compute the product of each of those pairs and sort the results in ascending order, what will be the K-th number in that list?
[{"input": "4 3\n 3 3 -4 -2", "output": "-6\n \n\nThere are six ways to form a pair. The products of those pairs are 9, -12, -6,\n-12, -6, 8.\n\nSorting those numbers in ascending order, we have -12, -12, -6, -6, 8, 9. The\nthird number in this list is -6.\n\n* * *"}, {"input": "10 40\n 5 4 3 2 -1 0 0 0 0 0", "output": "6\n \n\n* * *"}, {"input": "30 413\n -170202098 -268409015 537203564 983211703 21608710 -443999067 -937727165 -97596546 -372334013 398994917 -972141167 798607104 -949068442 -959948616 37909651 0 886627544 -20098238 0 -948955241 0 -214720580 277222296 -18897162 834475626 0 -425610555 110117526 663621752 0", "output": "448283280358331064"}]
Print the answer. * * *
s532571423
Wrong Answer
p02774
Input is given from Standard Input in the following format: N K A_1 A_2 \dots A_N
k = int(input().split()[1]) source = input().split() target = [] print(len(source)) for j in range(0, len(source)): num = source[j] for i in range(j + 1, len(source)): # for i in range(0, len(sorted_source)): target.append(int(num) * int(source[i])) # sorted_target=list(reversed(sorted(target))) print(target) sorted_target = sorted(target) print(sorted_target) print(sorted_target[k - 1])
Statement We have N integers A_1, A_2, ..., A_N. There are \frac{N(N-1)}{2} ways to choose two of them and form a pair. If we compute the product of each of those pairs and sort the results in ascending order, what will be the K-th number in that list?
[{"input": "4 3\n 3 3 -4 -2", "output": "-6\n \n\nThere are six ways to form a pair. The products of those pairs are 9, -12, -6,\n-12, -6, 8.\n\nSorting those numbers in ascending order, we have -12, -12, -6, -6, 8, 9. The\nthird number in this list is -6.\n\n* * *"}, {"input": "10 40\n 5 4 3 2 -1 0 0 0 0 0", "output": "6\n \n\n* * *"}, {"input": "30 413\n -170202098 -268409015 537203564 983211703 21608710 -443999067 -937727165 -97596546 -372334013 398994917 -972141167 798607104 -949068442 -959948616 37909651 0 886627544 -20098238 0 -948955241 0 -214720580 277222296 -18897162 834475626 0 -425610555 110117526 663621752 0", "output": "448283280358331064"}]
Print the answer. * * *
s389897767
Runtime Error
p02774
Input is given from Standard Input in the following format: N K A_1 A_2 \dots A_N
NandK = input() NandK = NandK.split(" ") N = int(NandK[0]) K = int(NandK[1]) anslist = [] A = input() A = A.split(" ") for k in range(len(A)): for j in range(k + 1, len(A)): anslist.append(int(A[k]) * int(A[j])) anslist.sort() print(anslist[K])
Statement We have N integers A_1, A_2, ..., A_N. There are \frac{N(N-1)}{2} ways to choose two of them and form a pair. If we compute the product of each of those pairs and sort the results in ascending order, what will be the K-th number in that list?
[{"input": "4 3\n 3 3 -4 -2", "output": "-6\n \n\nThere are six ways to form a pair. The products of those pairs are 9, -12, -6,\n-12, -6, 8.\n\nSorting those numbers in ascending order, we have -12, -12, -6, -6, 8, 9. The\nthird number in this list is -6.\n\n* * *"}, {"input": "10 40\n 5 4 3 2 -1 0 0 0 0 0", "output": "6\n \n\n* * *"}, {"input": "30 413\n -170202098 -268409015 537203564 983211703 21608710 -443999067 -937727165 -97596546 -372334013 398994917 -972141167 798607104 -949068442 -959948616 37909651 0 886627544 -20098238 0 -948955241 0 -214720580 277222296 -18897162 834475626 0 -425610555 110117526 663621752 0", "output": "448283280358331064"}]
Print the answer. * * *
s700466527
Wrong Answer
p02774
Input is given from Standard Input in the following format: N K A_1 A_2 \dots A_N
n, k = map(int, input().split()) l = list(map(int, input().split())) result = [] for i in range(len(l)): for j in range(len(l) - 1): result.append(l[i] * l[j + 1]) print(sorted(result)[k])
Statement We have N integers A_1, A_2, ..., A_N. There are \frac{N(N-1)}{2} ways to choose two of them and form a pair. If we compute the product of each of those pairs and sort the results in ascending order, what will be the K-th number in that list?
[{"input": "4 3\n 3 3 -4 -2", "output": "-6\n \n\nThere are six ways to form a pair. The products of those pairs are 9, -12, -6,\n-12, -6, 8.\n\nSorting those numbers in ascending order, we have -12, -12, -6, -6, 8, 9. The\nthird number in this list is -6.\n\n* * *"}, {"input": "10 40\n 5 4 3 2 -1 0 0 0 0 0", "output": "6\n \n\n* * *"}, {"input": "30 413\n -170202098 -268409015 537203564 983211703 21608710 -443999067 -937727165 -97596546 -372334013 398994917 -972141167 798607104 -949068442 -959948616 37909651 0 886627544 -20098238 0 -948955241 0 -214720580 277222296 -18897162 834475626 0 -425610555 110117526 663621752 0", "output": "448283280358331064"}]
Print the answer. * * *
s289297326
Wrong Answer
p02774
Input is given from Standard Input in the following format: N K A_1 A_2 \dots A_N
N, K = map(int, input().split()) # 数字 A = map(int, input().split()) # 数字 A = sorted(A, reverse=False) import bisect tmp = bisect.bisect_left(A, 0) C = A[:tmp] # 負の数 D = A[tmp:] # 正の数 D = D[::-1] # print(C) # print(D) B = [] # 負の数×正の数 cou = 0 E = 0 for i in range(len(C)): if E == 1: break for j in range(len(D)): B.append(C[i] * D[j]) cou += 1 if cou == K: E = 1 break # print(B) F = [] # 正数 cou2 = 0 G = [] # 負の数 cou3 = 0 if E == 0: D = D[::-1] for i in range(len(D)): if E == 1: break for j in range(i + 1, len(D)): F.append(D[i] * D[j]) cou2 += 1 if cou + cou2 == K: E = 1 break E = 0 for i in range(len(C)): if E == 1: break for j in range(i + 1, len(C)): G.append(C[i] * C[j]) cou3 += 1 if cou + cou3 == K: E = 1 break # print(F) # print(G) B = B + F + G B = sorted(B, reverse=False) # print(B) # print(len(B)) print(B[K - 1])
Statement We have N integers A_1, A_2, ..., A_N. There are \frac{N(N-1)}{2} ways to choose two of them and form a pair. If we compute the product of each of those pairs and sort the results in ascending order, what will be the K-th number in that list?
[{"input": "4 3\n 3 3 -4 -2", "output": "-6\n \n\nThere are six ways to form a pair. The products of those pairs are 9, -12, -6,\n-12, -6, 8.\n\nSorting those numbers in ascending order, we have -12, -12, -6, -6, 8, 9. The\nthird number in this list is -6.\n\n* * *"}, {"input": "10 40\n 5 4 3 2 -1 0 0 0 0 0", "output": "6\n \n\n* * *"}, {"input": "30 413\n -170202098 -268409015 537203564 983211703 21608710 -443999067 -937727165 -97596546 -372334013 398994917 -972141167 798607104 -949068442 -959948616 37909651 0 886627544 -20098238 0 -948955241 0 -214720580 277222296 -18897162 834475626 0 -425610555 110117526 663621752 0", "output": "448283280358331064"}]
Print the answer. * * *
s947207905
Runtime Error
p02774
Input is given from Standard Input in the following format: N K A_1 A_2 \dots A_N
N, K = map(int, input().split()) lis = list(map(int, input().split())) lis = sorted(lis) def find_nega(k, nega, posi): resu = [0] * (len(nega) * (len(posi))) a = 0 for i in nega: for j in posi: resu[a] = i * j a += 1 resu = sorted(resu) return resu[k - 1] def find_posi(k, nega, posi): resu = [0] * (len(posi) * (len(posi) - 1) // 2 + len(nega) * (len(nega) - 1) // 2) a = 0 for i in range(len(posi)): for j in range(i + 1, len(posi)): resu[a] = posi[i] * posi[j] a += 1 for i in range(len(nega)): for j in range(i + 1, len(nega)): resu[a] = nega[i] * nega[j] a += 1 resu = sorted(resu) return resu[k - 1] flag = -1 nega_point = 0 posi_point = N for i in range(len(lis)): if lis[i] >= 0 and flag == -1: nega_point = i flag = -2 if lis[i] >= 1 and flag < 0: posi_point = i flag = 1 break nega = lis[0:nega_point] zero = lis[nega_point:posi_point] posi = lis[posi_point:N] nega_num = len(nega) * len(posi) zero_num = (len(nega) + len(posi)) * len(zero) + len(zero) * (len(zero) - 1) // 2 posi_num = len(posi) * (len(posi) - 1) // 2 + len(nega) * (len(nega) - 1) // 2 if K <= nega_num: result = find_nega(K, nega, posi) elif K <= nega_num + zero_num: result = 0 else: result = find_posi(K - nega_num - zero_num, nega, posi) print(result)
Statement We have N integers A_1, A_2, ..., A_N. There are \frac{N(N-1)}{2} ways to choose two of them and form a pair. If we compute the product of each of those pairs and sort the results in ascending order, what will be the K-th number in that list?
[{"input": "4 3\n 3 3 -4 -2", "output": "-6\n \n\nThere are six ways to form a pair. The products of those pairs are 9, -12, -6,\n-12, -6, 8.\n\nSorting those numbers in ascending order, we have -12, -12, -6, -6, 8, 9. The\nthird number in this list is -6.\n\n* * *"}, {"input": "10 40\n 5 4 3 2 -1 0 0 0 0 0", "output": "6\n \n\n* * *"}, {"input": "30 413\n -170202098 -268409015 537203564 983211703 21608710 -443999067 -937727165 -97596546 -372334013 398994917 -972141167 798607104 -949068442 -959948616 37909651 0 886627544 -20098238 0 -948955241 0 -214720580 277222296 -18897162 834475626 0 -425610555 110117526 663621752 0", "output": "448283280358331064"}]
Print the answer. * * *
s782272581
Runtime Error
p02774
Input is given from Standard Input in the following format: N K A_1 A_2 \dots A_N
from scipy.misc import comb N, K = (int(x) for x in input().split(" ")) A = [int(x) for x in input().split(" ")] def mlDevelopment(PL, ML): ret = [] for i in PL: for j in ML: ret += [i * j] return sorted(ret) def plDevelopment(PL, ML): ret = [] # 正の数同士の積 if len(PL) > 1: for i in range(0, len(PL) - 1): for j in range(i + 1, len(PL)): ret += [PL[i] * PL[j]] else: ret += PL # 負の数同士の積 if len(ML) > 1: for i in range(0, len(ML) - 1): for j in range(i + 1, len(ML)): ret += [ML[i] * ML[j]] else: ret += ML return sorted(ret) # Aの中身を、正の数・負の数・マイナスに分けて再格納 PL = [] ML = [] ZL = [] for row in A: if row == 0: ZL = ZL + [0] elif row > 0: PL = PL + [row] else: ML = ML + [row] # 「負の数」「ゼロ」「正の数」と並ぶのでそれぞれの要素数を求める。 PC = comb(len(PL), 2, exact=True) + comb(len(ML), 2, exact=True) MC = len(PL) * len(ML) ZC = len(PL) * len(ZL) + len(ML) * len(ZL) + comb(len(ZL), 2, exact=True) # 探索値の所属する場所を特定する posi = 0 tgls = [] if MC > K: # print('マイナス値') tglc = mlDevelopment(PL, ML) ans = tglc[K - 1] else: if MC + ZC > K: # print('ゼロ') ans = 0 else: # print('プラス値') tglc = plDevelopment(PL, ML) ans = tglc[K - (MC + ZC + PC) - 1] print(ans)
Statement We have N integers A_1, A_2, ..., A_N. There are \frac{N(N-1)}{2} ways to choose two of them and form a pair. If we compute the product of each of those pairs and sort the results in ascending order, what will be the K-th number in that list?
[{"input": "4 3\n 3 3 -4 -2", "output": "-6\n \n\nThere are six ways to form a pair. The products of those pairs are 9, -12, -6,\n-12, -6, 8.\n\nSorting those numbers in ascending order, we have -12, -12, -6, -6, 8, 9. The\nthird number in this list is -6.\n\n* * *"}, {"input": "10 40\n 5 4 3 2 -1 0 0 0 0 0", "output": "6\n \n\n* * *"}, {"input": "30 413\n -170202098 -268409015 537203564 983211703 21608710 -443999067 -937727165 -97596546 -372334013 398994917 -972141167 798607104 -949068442 -959948616 37909651 0 886627544 -20098238 0 -948955241 0 -214720580 277222296 -18897162 834475626 0 -425610555 110117526 663621752 0", "output": "448283280358331064"}]
Print the answer. * * *
s460706130
Runtime Error
p02774
Input is given from Standard Input in the following format: N K A_1 A_2 \dots A_N
import sys N, K = map(int, sys.stdin.readline().split()) A = tuple(map(int, sys.stdin.readline().split())) UnderZeroA = tuple([a for a in A if a < 0]) ZeroA = tuple([a for a in A if a == 0]) OverZeroA = tuple([a for a in A if a > 0]) L_UnderZeroA = len(UnderZeroA) L_ZeroA = len(ZeroA) L_OverZeroA = len(OverZeroA) L_UnderZero = L_UnderZeroA * L_OverZeroA L_Zero = L_ZeroA * (L_UnderZeroA + L_OverZeroA) + L_ZeroA * (L_ZeroA - 1) // 2 L_OverZero = N * (N - 1) // 2 - L_UnderZero - L_Zero if K < L_UnderZero: arr = [None] * (L_UnderZeroA * L_OverZeroA) for i, u in enumerate(UnderZeroA): for j, o in enumerate(OverZeroA): arr[i * L_OverZeroA + j] = u * o arr.sort() print(arr[K - 1]) elif K > L_UnderZero + L_Zero: arr1 = [None] * (L_UnderZeroA * (L_UnderZeroA - 1) // 2) arr2 = [None] * (L_OverZeroA * (L_OverZeroA - 1) // 2) if L_UnderZeroA > 0: for i in range(L_UnderZeroA - 1): for j in range(i + 1, L_UnderZeroA): arr1[i * (L_UnderZeroA - 1) + (j - i - 1) - (i - 1) * i // 2] = ( UnderZeroA[i] * UnderZeroA[j] ) if L_OverZeroA > 0: for i in range(L_OverZeroA - 1): for j in range(i + 1, L_OverZeroA): arr2[i * (L_OverZeroA - 1) + (j - i - 1) - (i - 1) * i // 2] = ( OverZeroA[i] * OverZeroA[j] ) arr = arr1 + arr2 arr.sort() index = K - L_UnderZero - L_Zero print(arr[index - 1]) else: print(0)
Statement We have N integers A_1, A_2, ..., A_N. There are \frac{N(N-1)}{2} ways to choose two of them and form a pair. If we compute the product of each of those pairs and sort the results in ascending order, what will be the K-th number in that list?
[{"input": "4 3\n 3 3 -4 -2", "output": "-6\n \n\nThere are six ways to form a pair. The products of those pairs are 9, -12, -6,\n-12, -6, 8.\n\nSorting those numbers in ascending order, we have -12, -12, -6, -6, 8, 9. The\nthird number in this list is -6.\n\n* * *"}, {"input": "10 40\n 5 4 3 2 -1 0 0 0 0 0", "output": "6\n \n\n* * *"}, {"input": "30 413\n -170202098 -268409015 537203564 983211703 21608710 -443999067 -937727165 -97596546 -372334013 398994917 -972141167 798607104 -949068442 -959948616 37909651 0 886627544 -20098238 0 -948955241 0 -214720580 277222296 -18897162 834475626 0 -425610555 110117526 663621752 0", "output": "448283280358331064"}]
Print the answer. * * *
s554306534
Runtime Error
p02774
Input is given from Standard Input in the following format: N K A_1 A_2 \dots A_N
nk = list(map(int, input().split())) n = nk[0] k = nk[1] a = list(map(int, input().split())) a_posi = [] a_nega = [] a_zero = [] for aa in a: if aa > 0: a_posi.append(aa) elif aa == 0: a_zero.append(aa) else: a_nega.append(aa) a_posi.sort() a_nega.sort() num_a_posi = len(a_posi) num_a_nega = len(a_nega) num_a_zero = len(a_zero) def combination(n): return n * (n - 1) / 2 num_posi_result = combination(num_a_posi) + combination(num_a_nega) num_nega_result = num_a_posi * num_a_nega num_zero_result = combination(n) - num_posi_result - num_nega_result nega_posi = 0 if k <= num_nega_result: nega_posi = -1 else: k -= num_nega_result if k <= num_zero_result: nega_posi = 0 else: k -= num_zero_result nega_posi = 1 target_list = [] if nega_posi == -1: for ap in a_posi: target_list_ = [] for an in a_nega: target_list_.append(ap * an) target_list.append(target_list_) elif nega_posi == 0: target_list.append(0) else: for i in range(len(a_posi)): target_list_ = [] for j in range(i + 1, len(a_posi)): target_list_.append(a_posi[i] * a_posi[j]) target_list.append(target_list_) for i in range(len(a_nega)): target_list_ = [] for j in range(i + 1, len(a_nega)): target_list.append(a_nega[i] * a_nega[j]) target_list.append(target_list_) index = 0 r = 0 while index < k: b = [x[0] for x in target_list] min_index = b.index(min(b)) r = min(b) target_list[min_index].pop(0) index += 1 print(r)
Statement We have N integers A_1, A_2, ..., A_N. There are \frac{N(N-1)}{2} ways to choose two of them and form a pair. If we compute the product of each of those pairs and sort the results in ascending order, what will be the K-th number in that list?
[{"input": "4 3\n 3 3 -4 -2", "output": "-6\n \n\nThere are six ways to form a pair. The products of those pairs are 9, -12, -6,\n-12, -6, 8.\n\nSorting those numbers in ascending order, we have -12, -12, -6, -6, 8, 9. The\nthird number in this list is -6.\n\n* * *"}, {"input": "10 40\n 5 4 3 2 -1 0 0 0 0 0", "output": "6\n \n\n* * *"}, {"input": "30 413\n -170202098 -268409015 537203564 983211703 21608710 -443999067 -937727165 -97596546 -372334013 398994917 -972141167 798607104 -949068442 -959948616 37909651 0 886627544 -20098238 0 -948955241 0 -214720580 277222296 -18897162 834475626 0 -425610555 110117526 663621752 0", "output": "448283280358331064"}]
Print the answer. * * *
s026501293
Runtime Error
p02774
Input is given from Standard Input in the following format: N K A_1 A_2 \dots A_N
n = int(input()) sl = list(input() for _ in range(n)) sl_s = sorted(list(set(sl))) # if len(sl_s) == 1: # print(sl[0]) # else: # ans = [] # count = 1 # for s in sl_s: # if sl.count(s) == count and ans.count(s) == 0: # ans.append(s) # elif sl.count(s) > count and ans.count(s) == 0: # ans.clear() # ans.append(s) # count = sl.count(s) # print('\n'.join(ans)) dict = {} for s in sl: if s in dict: dict[s] += 1 else: dict[s] = 1 ans_ = [k for k, v in dict.items() if v == max(dict.values())] ans = "\n".join(sorted(ans_)) print(ans)
Statement We have N integers A_1, A_2, ..., A_N. There are \frac{N(N-1)}{2} ways to choose two of them and form a pair. If we compute the product of each of those pairs and sort the results in ascending order, what will be the K-th number in that list?
[{"input": "4 3\n 3 3 -4 -2", "output": "-6\n \n\nThere are six ways to form a pair. The products of those pairs are 9, -12, -6,\n-12, -6, 8.\n\nSorting those numbers in ascending order, we have -12, -12, -6, -6, 8, 9. The\nthird number in this list is -6.\n\n* * *"}, {"input": "10 40\n 5 4 3 2 -1 0 0 0 0 0", "output": "6\n \n\n* * *"}, {"input": "30 413\n -170202098 -268409015 537203564 983211703 21608710 -443999067 -937727165 -97596546 -372334013 398994917 -972141167 798607104 -949068442 -959948616 37909651 0 886627544 -20098238 0 -948955241 0 -214720580 277222296 -18897162 834475626 0 -425610555 110117526 663621752 0", "output": "448283280358331064"}]
Print the answer. * * *
s879989737
Runtime Error
p02774
Input is given from Standard Input in the following format: N K A_1 A_2 \dots A_N
n, k = map(int, input().split(" ")) num = list(map(int, input().split(" "))).sort() p_num = [i for i in num if i > 0] zero_num = [i for i in num if i == 0] n_num = [i for i in num if i < 0] positive = len(p_num) * (len(p_num) - 1) + len(n_num) * (len(n_num) - 1) zero = len(zero_num) * (len(p_num) + len(n_num)) negative = len(n_num) * len(p_num) if k - negative <= 0: multiplication_list = [i * j for i in n_num for j in n_num] multiplication_list.sort() print(multiplication_list[k - 1]) elif k - n_num - zero <= 0: print(0) else: idx = k - n_num - zero multiplication_list_1 = [ p_num[i] * p_num[j] for i in range(len(p_num)) for j in range(i + 1, len(p_num)) ] multiplication_list_2 = multiplication_list = [ n_num[i] * n_num[j] for i in range(len(n_num)) for j in range(i + 1, len(n_num)) ] multiplication_list = multiplication_list_1 + multiplication_list_2 multiplication_list.sort() print(multiplication_list[idx])
Statement We have N integers A_1, A_2, ..., A_N. There are \frac{N(N-1)}{2} ways to choose two of them and form a pair. If we compute the product of each of those pairs and sort the results in ascending order, what will be the K-th number in that list?
[{"input": "4 3\n 3 3 -4 -2", "output": "-6\n \n\nThere are six ways to form a pair. The products of those pairs are 9, -12, -6,\n-12, -6, 8.\n\nSorting those numbers in ascending order, we have -12, -12, -6, -6, 8, 9. The\nthird number in this list is -6.\n\n* * *"}, {"input": "10 40\n 5 4 3 2 -1 0 0 0 0 0", "output": "6\n \n\n* * *"}, {"input": "30 413\n -170202098 -268409015 537203564 983211703 21608710 -443999067 -937727165 -97596546 -372334013 398994917 -972141167 798607104 -949068442 -959948616 37909651 0 886627544 -20098238 0 -948955241 0 -214720580 277222296 -18897162 834475626 0 -425610555 110117526 663621752 0", "output": "448283280358331064"}]
Print the answer. * * *
s549081846
Wrong Answer
p02774
Input is given from Standard Input in the following format: N K A_1 A_2 \dots A_N
n, k = map(int, input().split()) p = list(map(int, input().split())) # slice tmp = sum(p[:k]) res = tmp for i in range(n - k): tmp -= p[i] tmp += p[i + k] res = max(res, tmp) print((res + k) / 2)
Statement We have N integers A_1, A_2, ..., A_N. There are \frac{N(N-1)}{2} ways to choose two of them and form a pair. If we compute the product of each of those pairs and sort the results in ascending order, what will be the K-th number in that list?
[{"input": "4 3\n 3 3 -4 -2", "output": "-6\n \n\nThere are six ways to form a pair. The products of those pairs are 9, -12, -6,\n-12, -6, 8.\n\nSorting those numbers in ascending order, we have -12, -12, -6, -6, 8, 9. The\nthird number in this list is -6.\n\n* * *"}, {"input": "10 40\n 5 4 3 2 -1 0 0 0 0 0", "output": "6\n \n\n* * *"}, {"input": "30 413\n -170202098 -268409015 537203564 983211703 21608710 -443999067 -937727165 -97596546 -372334013 398994917 -972141167 798607104 -949068442 -959948616 37909651 0 886627544 -20098238 0 -948955241 0 -214720580 277222296 -18897162 834475626 0 -425610555 110117526 663621752 0", "output": "448283280358331064"}]
Print the answer. * * *
s048459007
Wrong Answer
p02774
Input is given from Standard Input in the following format: N K A_1 A_2 \dots A_N
def getProduct(n, m): product = 1 for i in range(2, len(n)): product *= pow(n[i], m[i]) return product
Statement We have N integers A_1, A_2, ..., A_N. There are \frac{N(N-1)}{2} ways to choose two of them and form a pair. If we compute the product of each of those pairs and sort the results in ascending order, what will be the K-th number in that list?
[{"input": "4 3\n 3 3 -4 -2", "output": "-6\n \n\nThere are six ways to form a pair. The products of those pairs are 9, -12, -6,\n-12, -6, 8.\n\nSorting those numbers in ascending order, we have -12, -12, -6, -6, 8, 9. The\nthird number in this list is -6.\n\n* * *"}, {"input": "10 40\n 5 4 3 2 -1 0 0 0 0 0", "output": "6\n \n\n* * *"}, {"input": "30 413\n -170202098 -268409015 537203564 983211703 21608710 -443999067 -937727165 -97596546 -372334013 398994917 -972141167 798607104 -949068442 -959948616 37909651 0 886627544 -20098238 0 -948955241 0 -214720580 277222296 -18897162 834475626 0 -425610555 110117526 663621752 0", "output": "448283280358331064"}]
Print the answer. * * *
s467808946
Runtime Error
p02774
Input is given from Standard Input in the following format: N K A_1 A_2 \dots A_N
import sys lines = [l for l in sys.stdin] l = lines[0].split(" ") N, K = int(l[0]), int(l[1]) nums = [int(s) for s in lines[1].split(" ")] rets = [] for idx, n1 in enumerate(nums[:-1]): for idy, n2 in enumerate(nums[idx + 1]): rets.append(n1 * n2) rets.sort() print(rets[K])
Statement We have N integers A_1, A_2, ..., A_N. There are \frac{N(N-1)}{2} ways to choose two of them and form a pair. If we compute the product of each of those pairs and sort the results in ascending order, what will be the K-th number in that list?
[{"input": "4 3\n 3 3 -4 -2", "output": "-6\n \n\nThere are six ways to form a pair. The products of those pairs are 9, -12, -6,\n-12, -6, 8.\n\nSorting those numbers in ascending order, we have -12, -12, -6, -6, 8, 9. The\nthird number in this list is -6.\n\n* * *"}, {"input": "10 40\n 5 4 3 2 -1 0 0 0 0 0", "output": "6\n \n\n* * *"}, {"input": "30 413\n -170202098 -268409015 537203564 983211703 21608710 -443999067 -937727165 -97596546 -372334013 398994917 -972141167 798607104 -949068442 -959948616 37909651 0 886627544 -20098238 0 -948955241 0 -214720580 277222296 -18897162 834475626 0 -425610555 110117526 663621752 0", "output": "448283280358331064"}]
Print the answer. * * *
s836539767
Wrong Answer
p02774
Input is given from Standard Input in the following format: N K A_1 A_2 \dots A_N
print(0)
Statement We have N integers A_1, A_2, ..., A_N. There are \frac{N(N-1)}{2} ways to choose two of them and form a pair. If we compute the product of each of those pairs and sort the results in ascending order, what will be the K-th number in that list?
[{"input": "4 3\n 3 3 -4 -2", "output": "-6\n \n\nThere are six ways to form a pair. The products of those pairs are 9, -12, -6,\n-12, -6, 8.\n\nSorting those numbers in ascending order, we have -12, -12, -6, -6, 8, 9. The\nthird number in this list is -6.\n\n* * *"}, {"input": "10 40\n 5 4 3 2 -1 0 0 0 0 0", "output": "6\n \n\n* * *"}, {"input": "30 413\n -170202098 -268409015 537203564 983211703 21608710 -443999067 -937727165 -97596546 -372334013 398994917 -972141167 798607104 -949068442 -959948616 37909651 0 886627544 -20098238 0 -948955241 0 -214720580 277222296 -18897162 834475626 0 -425610555 110117526 663621752 0", "output": "448283280358331064"}]
Print the answer. * * *
s892395244
Runtime Error
p02774
Input is given from Standard Input in the following format: N K A_1 A_2 \dots A_N
n = str(input()) l = len(n) c = 0 n = "00" + n dnow = int(n[l + 1]) for i in range(l + 1): dnext = int(n[l - i]) if dnow <= 4: c += dnow elif dnow == 5: if dnext <= 4: c += 5 else: dnext += 1 c += 5 elif dnow == 10: dnext += 1 else: c += 10 - dnow dnext += 1 dnow = dnext print(c)
Statement We have N integers A_1, A_2, ..., A_N. There are \frac{N(N-1)}{2} ways to choose two of them and form a pair. If we compute the product of each of those pairs and sort the results in ascending order, what will be the K-th number in that list?
[{"input": "4 3\n 3 3 -4 -2", "output": "-6\n \n\nThere are six ways to form a pair. The products of those pairs are 9, -12, -6,\n-12, -6, 8.\n\nSorting those numbers in ascending order, we have -12, -12, -6, -6, 8, 9. The\nthird number in this list is -6.\n\n* * *"}, {"input": "10 40\n 5 4 3 2 -1 0 0 0 0 0", "output": "6\n \n\n* * *"}, {"input": "30 413\n -170202098 -268409015 537203564 983211703 21608710 -443999067 -937727165 -97596546 -372334013 398994917 -972141167 798607104 -949068442 -959948616 37909651 0 886627544 -20098238 0 -948955241 0 -214720580 277222296 -18897162 834475626 0 -425610555 110117526 663621752 0", "output": "448283280358331064"}]
Print the answer. * * *
s632997461
Runtime Error
p02774
Input is given from Standard Input in the following format: N K A_1 A_2 \dots A_N
# from itertools import * class Combination: """ O(n)の前計算を1回行うことで,O(1)でnCr mod mを求められる n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms) 使用例: comb = Combination(1000000) print(comb(5, 3)) # 10 """ def __init__(self, n_max, mod=10**9 + 7): self.mod = mod self.modinv = self.make_modinv_list(n_max) self.fac, self.facinv = self.make_factorial_list(n_max) def __call__(self, n, r): return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n - r] % self.mod def make_factorial_list(self, n): # 階乗のリストと階乗のmod逆元のリストを返す O(n) # self.make_modinv_list()が先に実行されている必要がある fac = [1] facinv = [1] for i in range(1, n + 1): fac.append(fac[i - 1] * i % self.mod) facinv.append(facinv[i - 1] * self.modinv[i] % self.mod) return fac, facinv def make_modinv_list(self, n): # 0からnまでのmod逆元のリストを返す O(n) modinv = [0] * (n + 1) modinv[1] = 1 for i in range(2, n + 1): modinv[i] = self.mod - self.mod // i * modinv[self.mod % i] % self.mod return modinv n, k = map(int, input().split()) a = list(map(int, input().split())) c = Combination(1000000) # c = list(combinations(a, 2)) p = [] for i in range(len(c)): p.append(c[i][0] * c[i][1]) p.sort() print(p[k - 1])
Statement We have N integers A_1, A_2, ..., A_N. There are \frac{N(N-1)}{2} ways to choose two of them and form a pair. If we compute the product of each of those pairs and sort the results in ascending order, what will be the K-th number in that list?
[{"input": "4 3\n 3 3 -4 -2", "output": "-6\n \n\nThere are six ways to form a pair. The products of those pairs are 9, -12, -6,\n-12, -6, 8.\n\nSorting those numbers in ascending order, we have -12, -12, -6, -6, 8, 9. The\nthird number in this list is -6.\n\n* * *"}, {"input": "10 40\n 5 4 3 2 -1 0 0 0 0 0", "output": "6\n \n\n* * *"}, {"input": "30 413\n -170202098 -268409015 537203564 983211703 21608710 -443999067 -937727165 -97596546 -372334013 398994917 -972141167 798607104 -949068442 -959948616 37909651 0 886627544 -20098238 0 -948955241 0 -214720580 277222296 -18897162 834475626 0 -425610555 110117526 663621752 0", "output": "448283280358331064"}]
Print the answer. * * *
s821059993
Runtime Error
p02774
Input is given from Standard Input in the following format: N K A_1 A_2 \dots A_N
import numpy as np N, K = map(int, input().split()) aa = np.array(list(map(int, input().split()))) # p = [aa[i] * aa[j] for i in range(N-1) for j in range(i+1, N)] """ for i in range(N-1): for j in range(i+1, N): p.append() """ p = aa[:, np.newaxis] * aa[np.newaxis].astype(float) f = np.tril(np.ones((N, N))) # print(f) p[f == 0] = np.nan q = p.flatten() q.sort() # print(q) # print(p) # p = list(set(p)) print(int(q[K - 1]))
Statement We have N integers A_1, A_2, ..., A_N. There are \frac{N(N-1)}{2} ways to choose two of them and form a pair. If we compute the product of each of those pairs and sort the results in ascending order, what will be the K-th number in that list?
[{"input": "4 3\n 3 3 -4 -2", "output": "-6\n \n\nThere are six ways to form a pair. The products of those pairs are 9, -12, -6,\n-12, -6, 8.\n\nSorting those numbers in ascending order, we have -12, -12, -6, -6, 8, 9. The\nthird number in this list is -6.\n\n* * *"}, {"input": "10 40\n 5 4 3 2 -1 0 0 0 0 0", "output": "6\n \n\n* * *"}, {"input": "30 413\n -170202098 -268409015 537203564 983211703 21608710 -443999067 -937727165 -97596546 -372334013 398994917 -972141167 798607104 -949068442 -959948616 37909651 0 886627544 -20098238 0 -948955241 0 -214720580 277222296 -18897162 834475626 0 -425610555 110117526 663621752 0", "output": "448283280358331064"}]
Print the answer. * * *
s165632191
Wrong Answer
p02774
Input is given from Standard Input in the following format: N K A_1 A_2 \dots A_N
n, k = map(int, input().split()) a = list(map(int, input().split())) # b1,b3はそれぞれ絶対値の大きい順に並ぶ b1 = sorted([i for i in a if i < 0]) l1 = len(b1) b2 = sorted([i for i in a if i == 0]) l2 = len(b2) b3 = sorted([i for i in a if i > 0], reverse=True) l3 = len(b3) def countk1(x, b11, b13): # x以下になるものの個数 ret = 0 for i in range(l1): lx, rx = 0, l3 - 1 while lx + 1 < rx: if b13[(lx + rx) // 2] * b11[i] <= x: lx = (lx + rx) // 2 else: rx = (lx + rx) // 2 if b13[rx] * b11[i] <= x: ret += rx + 1 elif b13[lx] * b11[i] <= x: ret += lx + 1 return ret def countk2(x, b21, b23): # ここ数えすぎ ret = 0 for i in range(l1 - 1): lx, rx = i + 1, l1 - 1 while lx + 1 < rx: if b21[(lx + rx) // 2] * b21[i] <= x: lx = (lx + rx) // 2 else: rx = (lx + rx) // 2 if b21[rx] * b21[i] <= x: ret += rx - i elif b21[lx] * b21[i] <= x: ret += lx - i for i in range(l3 - 1): lx, rx = i + 1, l3 - 1 while lx + 1 < rx: if b23[(lx + rx) // 2] * b23[i] <= x: lx = (lx + rx) // 2 else: rx = (lx + rx) // 2 if b23[rx] * b23[i] <= x: ret += rx - i elif b23[lx] * b23[i] <= x: ret += lx - i return ret if k <= l1 * l3: l, r = b1[0] * b3[-1], -1 while l + 1 < r: if countk1((l + r) // 2, b1, b3) >= k: # k以上、数が存在するかどうか r = (l + r) // 2 else: l = (l + r) // 2 if countk1(l, b1, b3) == k: print(l) else: print(r) elif k <= l1 * l3 + l2 * (l1 + l3) + (l2 * (l2 - 1)) // 2: print(0) else: k -= l1 * l3 + l2 * (l1 + l3) + (l2 * (l2 - 1)) // 2 l = 1 if l1 >= 2 and l3 < 2: r = b1[0] * b1[1] elif l1 < 2 and l3 >= 2: r = b3[0] * b3[1] else: r = max(b1[0] * b1[1], b3[0] * b3[1]) while l + 1 < r: if ( countk2((l + r) // 2, sorted(b1, reverse=True), sorted(b3)) >= k ): # k以上、数が存在するかどうか r = (l + r) // 2 else: l = (l + r) // 2 if countk2(l, sorted(b1, reverse=True), sorted(b3)) == k: print(l) else: print(r)
Statement We have N integers A_1, A_2, ..., A_N. There are \frac{N(N-1)}{2} ways to choose two of them and form a pair. If we compute the product of each of those pairs and sort the results in ascending order, what will be the K-th number in that list?
[{"input": "4 3\n 3 3 -4 -2", "output": "-6\n \n\nThere are six ways to form a pair. The products of those pairs are 9, -12, -6,\n-12, -6, 8.\n\nSorting those numbers in ascending order, we have -12, -12, -6, -6, 8, 9. The\nthird number in this list is -6.\n\n* * *"}, {"input": "10 40\n 5 4 3 2 -1 0 0 0 0 0", "output": "6\n \n\n* * *"}, {"input": "30 413\n -170202098 -268409015 537203564 983211703 21608710 -443999067 -937727165 -97596546 -372334013 398994917 -972141167 798607104 -949068442 -959948616 37909651 0 886627544 -20098238 0 -948955241 0 -214720580 277222296 -18897162 834475626 0 -425610555 110117526 663621752 0", "output": "448283280358331064"}]
Print the answer. * * *
s660278044
Accepted
p02774
Input is given from Standard Input in the following format: N K A_1 A_2 \dots A_N
# D - Pairs import numpy as np N, K = map(int, input().split()) A = np.array(sorted(list(map(int, input().split()))), np.int64) n_zero = len(A[A == 0]) A_posi = A[A > 0] A_nega = A[A < 0] def n_pairs_less_than_or_equal_to_border(product_border): n_pairs = -np.sum( A * A <= product_border ) # i==jかつ条件を満たすペアの個数を先に引き、以降重複を許して数える n_pairs += n_zero * N * (product_border >= 0) n_pairs += np.searchsorted(A, product_border // A_posi, side="right").sum() n_pairs += (N - np.searchsorted(A, -(-product_border // A_nega), side="left")).sum() # 上記2行は下記と同様の処理だが下記の実装だとTLE # for i in range(N): # if A[i] > 0: # n_pairs += np.searchsorted(A, product_border//A[i], side="right") # elif A[i] < 0: # n_pairs += N - np.searchsorted(A, -(-product_border//A[i]), side="left") n_pairs //= 2 return n_pairs lower = -(10**18) upper = 10**18 while lower <= upper: x = (lower + upper) // 2 if n_pairs_less_than_or_equal_to_border(x) >= K: ans = x upper = x - 1 else: lower = x + 1 print(ans)
Statement We have N integers A_1, A_2, ..., A_N. There are \frac{N(N-1)}{2} ways to choose two of them and form a pair. If we compute the product of each of those pairs and sort the results in ascending order, what will be the K-th number in that list?
[{"input": "4 3\n 3 3 -4 -2", "output": "-6\n \n\nThere are six ways to form a pair. The products of those pairs are 9, -12, -6,\n-12, -6, 8.\n\nSorting those numbers in ascending order, we have -12, -12, -6, -6, 8, 9. The\nthird number in this list is -6.\n\n* * *"}, {"input": "10 40\n 5 4 3 2 -1 0 0 0 0 0", "output": "6\n \n\n* * *"}, {"input": "30 413\n -170202098 -268409015 537203564 983211703 21608710 -443999067 -937727165 -97596546 -372334013 398994917 -972141167 798607104 -949068442 -959948616 37909651 0 886627544 -20098238 0 -948955241 0 -214720580 277222296 -18897162 834475626 0 -425610555 110117526 663621752 0", "output": "448283280358331064"}]
Print the answer. * * *
s869882652
Runtime Error
p02774
Input is given from Standard Input in the following format: N K A_1 A_2 \dots A_N
count, index = input().split() ary = (int(x) for x in input().split()) ary1 = [] ary2 = [] for i in ary: ary1.append(i) ary2.append(i) seki = [] cnt1 = 0 cnt2 = 0 for i in ary1: # 半分行ったら終了 if cnt1 >= int(count) / 2: break for j in ary2: print(str(cnt1) + "|" + str(cnt2)) if cnt1 != cnt2: seki.append(i * j) cnt2 = cnt2 + 1 cnt2 = 0 cnt1 += 1 seki.sort() print(seki) print(seki[int(index)]) # print(seki[count[1]])
Statement We have N integers A_1, A_2, ..., A_N. There are \frac{N(N-1)}{2} ways to choose two of them and form a pair. If we compute the product of each of those pairs and sort the results in ascending order, what will be the K-th number in that list?
[{"input": "4 3\n 3 3 -4 -2", "output": "-6\n \n\nThere are six ways to form a pair. The products of those pairs are 9, -12, -6,\n-12, -6, 8.\n\nSorting those numbers in ascending order, we have -12, -12, -6, -6, 8, 9. The\nthird number in this list is -6.\n\n* * *"}, {"input": "10 40\n 5 4 3 2 -1 0 0 0 0 0", "output": "6\n \n\n* * *"}, {"input": "30 413\n -170202098 -268409015 537203564 983211703 21608710 -443999067 -937727165 -97596546 -372334013 398994917 -972141167 798607104 -949068442 -959948616 37909651 0 886627544 -20098238 0 -948955241 0 -214720580 277222296 -18897162 834475626 0 -425610555 110117526 663621752 0", "output": "448283280358331064"}]
Print the answer. * * *
s139010672
Wrong Answer
p02774
Input is given from Standard Input in the following format: N K A_1 A_2 \dots A_N
from bisect import bisect_left, bisect_right n, k = [int(s) for s in input().split()] a_list = [int(s) for s in input().split()] a_list.sort() li = bisect_left(a_list, 0) ri = bisect_right(a_list, 0) a_list_1 = a_list[:li] a_list_1_num = len(a_list_1) # print(a_list_1) a_list_2 = a_list[li:ri] a_list_2_num = len(a_list_2) # print(a_list_2) a_list_3 = a_list[ri:] a_list_3_num = len(a_list_3) # print(a_list_3) ans = None temp_num = a_list_1_num * a_list_3_num if k > temp_num: k -= temp_num else: i, j = divmod(k - 1, a_list_3_num) ans = a_list_1[i] * a_list_3[j - 1] if ans is None: temp_num = int( a_list_2_num * (a_list_1_num + (a_list_2_num - 1) / 2 + a_list_3_num) ) if k > temp_num: k -= temp_num else: ans = 0 if ans is None: a_list_1 = [-num for num in a_list_1] a_list_1.reverse() # print(a_list_1) if a_list_1_num > 1: temp_1 = a_list_1.pop(0) a_list_1_num -= 1 else: temp_1 = a_list_3[-1] + 1 if a_list_3_num > 1: temp_3 = a_list_3.pop(0) a_list_3_num -= 1 else: temp_3 = a_list_1[-1] + 1 for _ in range(a_list_1_num + a_list_3_num): # print(k, temp_1, temp_3) if temp_1 < temp_3: if k > a_list_1_num: k -= a_list_1_num if a_list_1_num > 1: temp_1 = a_list_1.pop(0) a_list_1_num -= 1 else: temp_1 = a_list_3[-1] + 1 continue ans = temp_1 * a_list_1[k - 1] break elif temp_1 > temp_3: if a_list_3_num == 0: a_list_3.append(a_list_1[-1] + 1) continue if k > a_list_3_num: k -= a_list_3_num if a_list_3_num > 1: temp_3 = a_list_3.pop(0) a_list_3_num -= 1 else: temp_3 = a_list_1[-1] + 1 continue ans = temp_3 * a_list_3[k - 1] break elif temp_1 == temp_3: if k > a_list_1_num + a_list_3_num: k -= a_list_1_num + a_list_3_num if a_list_1_num > 1: temp_1 = a_list_1.pop(0) a_list_1_num -= 1 else: temp_1 = a_list_3[-1] + 1 if a_list_3_num > 1: temp_3 = a_list_3.pop(0) a_list_3_num -= 1 else: temp_3 = a_list_1[-1] + 1 continue temp_list = [temp_1 * num for num in a_list_1] + [ temp_3 * num for num in a_list_3 ] temp_list.sort() ans = temp_list[k - 1] break print(ans)
Statement We have N integers A_1, A_2, ..., A_N. There are \frac{N(N-1)}{2} ways to choose two of them and form a pair. If we compute the product of each of those pairs and sort the results in ascending order, what will be the K-th number in that list?
[{"input": "4 3\n 3 3 -4 -2", "output": "-6\n \n\nThere are six ways to form a pair. The products of those pairs are 9, -12, -6,\n-12, -6, 8.\n\nSorting those numbers in ascending order, we have -12, -12, -6, -6, 8, 9. The\nthird number in this list is -6.\n\n* * *"}, {"input": "10 40\n 5 4 3 2 -1 0 0 0 0 0", "output": "6\n \n\n* * *"}, {"input": "30 413\n -170202098 -268409015 537203564 983211703 21608710 -443999067 -937727165 -97596546 -372334013 398994917 -972141167 798607104 -949068442 -959948616 37909651 0 886627544 -20098238 0 -948955241 0 -214720580 277222296 -18897162 834475626 0 -425610555 110117526 663621752 0", "output": "448283280358331064"}]
Print the answer. * * *
s443725520
Runtime Error
p02774
Input is given from Standard Input in the following format: N K A_1 A_2 \dots A_N
n, k = map(int, input().split()) lst = list(map(int, input().split())) minus = [l for l in lst if l < 0] zeros = [l for l in lst if l == 0] plus = [l for l in lst if l > 0] minus_num = len(minus) zeros_num = len(zeros) plus_num = len(plus) # print(minus) # print(plus) # print(zeros) d1 = minus_num * plus_num d2 = zeros_num * minus_num + zeros_num * plus_num + zeros_num * (zeros_num - 1) / 2 # print(d1) # print(d2) if k <= d1: values = [] for m in minus: for p in plus: values.append(m * p) print(sorted(values)[k]) elif d1 < k <= (d1 + d2): print(0) else: resi = int(k - d1 - d2) - 1 values = [] for i in range(len(minus)): for j in range(i + 1, len(minus)): values.append(minus[i] * minus[j]) for i in range(len(plus)): for j in range(i + 1, len(plus)): values.append(plus[i] * plus[j]) print(sorted(values)[resi])
Statement We have N integers A_1, A_2, ..., A_N. There are \frac{N(N-1)}{2} ways to choose two of them and form a pair. If we compute the product of each of those pairs and sort the results in ascending order, what will be the K-th number in that list?
[{"input": "4 3\n 3 3 -4 -2", "output": "-6\n \n\nThere are six ways to form a pair. The products of those pairs are 9, -12, -6,\n-12, -6, 8.\n\nSorting those numbers in ascending order, we have -12, -12, -6, -6, 8, 9. The\nthird number in this list is -6.\n\n* * *"}, {"input": "10 40\n 5 4 3 2 -1 0 0 0 0 0", "output": "6\n \n\n* * *"}, {"input": "30 413\n -170202098 -268409015 537203564 983211703 21608710 -443999067 -937727165 -97596546 -372334013 398994917 -972141167 798607104 -949068442 -959948616 37909651 0 886627544 -20098238 0 -948955241 0 -214720580 277222296 -18897162 834475626 0 -425610555 110117526 663621752 0", "output": "448283280358331064"}]
Print the minimum possible duration of time Snuke is exposed to cosmic rays during the travel. The output is considered correct if the absolute or relative error is at most 10^{-9}. * * *
s699933874
Accepted
p03866
The input is given from Standard Input in the following format: x_s y_s x_t y_t N x_1 y_1 r_1 x_2 y_2 r_2 : x_N y_N r_N
# 13:03 sx, sy, tx, ty = map(int, input().split()) raw = [[sx, sy, 0]] n = int(input()) + 2 for _ in range(n - 2): raw.append(list(map(int, input().split()))) raw.append([tx, ty, 0]) dist = [] for i in range(n): add = [] for j in range(n): tmp = (raw[i][0] - raw[j][0]) ** 2 + (raw[i][1] - raw[j][1]) ** 2 tmp **= 0.5 tmp -= raw[i][2] + raw[j][2] if tmp < 0: tmp = 0 add.append(tmp) dist.append(add) # print(dist) inf = 10**12 now = [] for i in range(n): now.append([dist[0][i], i]) now[0][0] = inf for _ in range(n - 1): d, j = min(now) if j == n - 1: print(d) now[j][0] = inf for i in range(n): if now[i][0] == inf: continue if now[i][0] > d + dist[i][j]: now[i][0] = d + dist[i][j]
Statement On the xy-plane, Snuke is going to travel from the point (x_s, y_s) to the point (x_t, y_t). He can move in arbitrary directions with speed 1. Here, we will consider him as a point without size. There are N circular barriers deployed on the plane. The center and the radius of the i-th barrier are (x_i, y_i) and r_i, respectively. The barriers may overlap or contain each other. A point on the plane is exposed to cosmic rays if the point is not within any of the barriers. Snuke wants to avoid exposure to cosmic rays as much as possible during the travel. Find the minimum possible duration of time he is exposed to cosmic rays during the travel.
[{"input": "-2 -2 2 2\n 1\n 0 0 1", "output": "3.6568542495\n \n\nAn optimal route is as follows:\n\n![e9c630751968b7051df5750b7ddc0e07.png](https://atcoder.jp/img/arc064/e9c630751968b7051df5750b7ddc0e07.png)\n\n* * *"}, {"input": "-2 0 2 0\n 2\n -1 0 2\n 1 0 2", "output": "0.0000000000\n \n\nAn optimal route is as follows:\n\n![fb82f6f4df5b22cffb868ce6333277aa.png](https://atcoder.jp/img/arc064/fb82f6f4df5b22cffb868ce6333277aa.png)\n\n* * *"}, {"input": "4 -2 -2 4\n 3\n 0 0 2\n 4 0 1\n 0 4 1", "output": "4.0000000000\n \n\nAn optimal route is as follows:\n\n![d09006720c225cbe69eae3fd9c186e67.png](https://atcoder.jp/img/arc064/d09006720c225cbe69eae3fd9c186e67.png)"}]
Print the minimum possible duration of time Snuke is exposed to cosmic rays during the travel. The output is considered correct if the absolute or relative error is at most 10^{-9}. * * *
s565109978
Accepted
p03866
The input is given from Standard Input in the following format: x_s y_s x_t y_t N x_1 y_1 r_1 x_2 y_2 r_2 : x_N y_N r_N
xs, ys, xe, ye = map(int, input().split()) n = int(input()) xyr = [tuple(map(int, input().split())) for _ in range(n)] xyr.append((xs, ys, 0)) xyr.append((xe, ye, 0)) d = [[0] * (n + 2) for _ in range(n + 2)] for i in range(n + 1): for j in range(i + 1, n + 2): x, y, r = xyr[i] nx, ny, nr = xyr[j] tmp = ((x - nx) ** 2 + (y - ny) ** 2) ** 0.5 tmp -= r + nr tmp = max(tmp, 0) d[i][j] = tmp d[j][i] = tmp inf = float("inf") seen = [inf] * (n + 2) seen[-2] = 0 mi = set(range(n + 2)) # n->n+1 while mi: min_idx = 0 min_d = inf for v in mi: if min_d > seen[v]: min_d = seen[v] min_idx = v v = min_idx mi.discard(v) if v == n + 1: break for nv in mi: seen[nv] = min(seen[nv], seen[v] + d[v][nv]) print(seen[-1])
Statement On the xy-plane, Snuke is going to travel from the point (x_s, y_s) to the point (x_t, y_t). He can move in arbitrary directions with speed 1. Here, we will consider him as a point without size. There are N circular barriers deployed on the plane. The center and the radius of the i-th barrier are (x_i, y_i) and r_i, respectively. The barriers may overlap or contain each other. A point on the plane is exposed to cosmic rays if the point is not within any of the barriers. Snuke wants to avoid exposure to cosmic rays as much as possible during the travel. Find the minimum possible duration of time he is exposed to cosmic rays during the travel.
[{"input": "-2 -2 2 2\n 1\n 0 0 1", "output": "3.6568542495\n \n\nAn optimal route is as follows:\n\n![e9c630751968b7051df5750b7ddc0e07.png](https://atcoder.jp/img/arc064/e9c630751968b7051df5750b7ddc0e07.png)\n\n* * *"}, {"input": "-2 0 2 0\n 2\n -1 0 2\n 1 0 2", "output": "0.0000000000\n \n\nAn optimal route is as follows:\n\n![fb82f6f4df5b22cffb868ce6333277aa.png](https://atcoder.jp/img/arc064/fb82f6f4df5b22cffb868ce6333277aa.png)\n\n* * *"}, {"input": "4 -2 -2 4\n 3\n 0 0 2\n 4 0 1\n 0 4 1", "output": "4.0000000000\n \n\nAn optimal route is as follows:\n\n![d09006720c225cbe69eae3fd9c186e67.png](https://atcoder.jp/img/arc064/d09006720c225cbe69eae3fd9c186e67.png)"}]
Print the minimum possible duration of time Snuke is exposed to cosmic rays during the travel. The output is considered correct if the absolute or relative error is at most 10^{-9}. * * *
s881077434
Runtime Error
p03866
The input is given from Standard Input in the following format: x_s y_s x_t y_t N x_1 y_1 r_1 x_2 y_2 r_2 : x_N y_N r_N
sx,sy,gx,gy=map(int,input().split()) n=int(input()) g = [[] for i in range(n+2)] data=[(sx,sy,0)] for i in range(n): data.append(tuple(map(int,input().split()))) data.append((gx,gy,0)) for i in range(n+2): for j in range(i+1,n+2): tmp=(data[i][0]-data[j][0])**2+(data[i][1]-data[j][1])**2)**0.5-data[i][2]-data[j][2] if tmp<0: tmp=0 g[i].append((tmp,j)) g[j].append((tmp,i)) def dijkstra(g,st,ed): from heapq import heappush, heappop, heapify dist=[2828427127 for i in range(len(g))] dist[st]=0 que=[] heappush(que,(0,st)) while que: c,v=heappop(que) if dist[v]<c: continue for i in range(len(g[v])): tmp=g[v][i][0]+c if tmp<dist[g[v][i][1]]: dist[g[v][i][1]]=tmp heappush(que,(tmp,g[v][i][1])) return dist[ed] print(dijkstra(g,0,n+1))
Statement On the xy-plane, Snuke is going to travel from the point (x_s, y_s) to the point (x_t, y_t). He can move in arbitrary directions with speed 1. Here, we will consider him as a point without size. There are N circular barriers deployed on the plane. The center and the radius of the i-th barrier are (x_i, y_i) and r_i, respectively. The barriers may overlap or contain each other. A point on the plane is exposed to cosmic rays if the point is not within any of the barriers. Snuke wants to avoid exposure to cosmic rays as much as possible during the travel. Find the minimum possible duration of time he is exposed to cosmic rays during the travel.
[{"input": "-2 -2 2 2\n 1\n 0 0 1", "output": "3.6568542495\n \n\nAn optimal route is as follows:\n\n![e9c630751968b7051df5750b7ddc0e07.png](https://atcoder.jp/img/arc064/e9c630751968b7051df5750b7ddc0e07.png)\n\n* * *"}, {"input": "-2 0 2 0\n 2\n -1 0 2\n 1 0 2", "output": "0.0000000000\n \n\nAn optimal route is as follows:\n\n![fb82f6f4df5b22cffb868ce6333277aa.png](https://atcoder.jp/img/arc064/fb82f6f4df5b22cffb868ce6333277aa.png)\n\n* * *"}, {"input": "4 -2 -2 4\n 3\n 0 0 2\n 4 0 1\n 0 4 1", "output": "4.0000000000\n \n\nAn optimal route is as follows:\n\n![d09006720c225cbe69eae3fd9c186e67.png](https://atcoder.jp/img/arc064/d09006720c225cbe69eae3fd9c186e67.png)"}]
Print the minimum possible duration of time Snuke is exposed to cosmic rays during the travel. The output is considered correct if the absolute or relative error is at most 10^{-9}. * * *
s950431093
Runtime Error
p03866
The input is given from Standard Input in the following format: x_s y_s x_t y_t N x_1 y_1 r_1 x_2 y_2 r_2 : x_N y_N r_N
def main() import sys input=sys.stdin.readline sx,sy,tx,ty=map(int,input().split()) n=int(input()) p=[(sx,sy,0)] for _ in range(n): x,y,r=map(int,input().split()) p.append((x,y,r)) p.append((tx,ty,0)) n+=2 edge=[[]for _ in range(n)] for i in range(n-1): for j in range(i+1,n): sx,sy,sr=p[i] tx,ty,tr=p[j] t=(abs(sx-tx)**2+abs(sy-ty)**2)**0.5 c=max(0,t-(sr+tr)) edge[i].append((j,c)) edge[j].append((i,c)) from heapq import heappop,heappush def dijkstra(s,n,edge): inf=10**20 ans=[inf]*n ans[s]=0 root=[-1]*n h=[[0,s]] while h: c,v=heappop(h) if ans[v]<c:continue for u,t in edge[v]: if c+t<ans[u]: ans[u]=c+t root[u]=v heappush(h,[c+t,u]) print(ans[n-1]) dijkstra(0,n,edge) if __name__ == "__main__": main()
Statement On the xy-plane, Snuke is going to travel from the point (x_s, y_s) to the point (x_t, y_t). He can move in arbitrary directions with speed 1. Here, we will consider him as a point without size. There are N circular barriers deployed on the plane. The center and the radius of the i-th barrier are (x_i, y_i) and r_i, respectively. The barriers may overlap or contain each other. A point on the plane is exposed to cosmic rays if the point is not within any of the barriers. Snuke wants to avoid exposure to cosmic rays as much as possible during the travel. Find the minimum possible duration of time he is exposed to cosmic rays during the travel.
[{"input": "-2 -2 2 2\n 1\n 0 0 1", "output": "3.6568542495\n \n\nAn optimal route is as follows:\n\n![e9c630751968b7051df5750b7ddc0e07.png](https://atcoder.jp/img/arc064/e9c630751968b7051df5750b7ddc0e07.png)\n\n* * *"}, {"input": "-2 0 2 0\n 2\n -1 0 2\n 1 0 2", "output": "0.0000000000\n \n\nAn optimal route is as follows:\n\n![fb82f6f4df5b22cffb868ce6333277aa.png](https://atcoder.jp/img/arc064/fb82f6f4df5b22cffb868ce6333277aa.png)\n\n* * *"}, {"input": "4 -2 -2 4\n 3\n 0 0 2\n 4 0 1\n 0 4 1", "output": "4.0000000000\n \n\nAn optimal route is as follows:\n\n![d09006720c225cbe69eae3fd9c186e67.png](https://atcoder.jp/img/arc064/d09006720c225cbe69eae3fd9c186e67.png)"}]
Print the minimum possible duration of time Snuke is exposed to cosmic rays during the travel. The output is considered correct if the absolute or relative error is at most 10^{-9}. * * *
s732255020
Accepted
p03866
The input is given from Standard Input in the following format: x_s y_s x_t y_t N x_1 y_1 r_1 x_2 y_2 r_2 : x_N y_N r_N
import sys import heapq as h stdin = sys.stdin ni = lambda: int(ns()) nl = lambda: list(map(int, stdin.readline().split())) nm = lambda: map(int, stdin.readline().split()) ns = lambda: stdin.readline().rstrip() def dist(p, q): px, py, pr = p qx, qy, qr = q d = ((px - qx) ** 2 + (py - qy) ** 2) ** 0.5 return max(d - (pr + qr), 0) xs, ys, xt, yt = nm() n = ni() pl = [(xs, ys, 0)] + [tuple(nm()) for _ in range(n)] + [(xt, yt, 0)] gr = [dict() for _ in range(n + 2)] for i in range(n + 1): for j in range(i + 1, n + 2): gr[i][j] = dist(pl[i], pl[j]) gr[j][i] = gr[i][j] dis = [float("inf")] * (n + 2) q = [(0, 0)] while q: d, v = h.heappop(q) if dis[v] <= d: continue dis[v] = d for x in gr[v]: if dis[x] > dis[v] + gr[v][x]: h.heappush(q, (dis[v] + gr[v][x], x)) print(dis[-1])
Statement On the xy-plane, Snuke is going to travel from the point (x_s, y_s) to the point (x_t, y_t). He can move in arbitrary directions with speed 1. Here, we will consider him as a point without size. There are N circular barriers deployed on the plane. The center and the radius of the i-th barrier are (x_i, y_i) and r_i, respectively. The barriers may overlap or contain each other. A point on the plane is exposed to cosmic rays if the point is not within any of the barriers. Snuke wants to avoid exposure to cosmic rays as much as possible during the travel. Find the minimum possible duration of time he is exposed to cosmic rays during the travel.
[{"input": "-2 -2 2 2\n 1\n 0 0 1", "output": "3.6568542495\n \n\nAn optimal route is as follows:\n\n![e9c630751968b7051df5750b7ddc0e07.png](https://atcoder.jp/img/arc064/e9c630751968b7051df5750b7ddc0e07.png)\n\n* * *"}, {"input": "-2 0 2 0\n 2\n -1 0 2\n 1 0 2", "output": "0.0000000000\n \n\nAn optimal route is as follows:\n\n![fb82f6f4df5b22cffb868ce6333277aa.png](https://atcoder.jp/img/arc064/fb82f6f4df5b22cffb868ce6333277aa.png)\n\n* * *"}, {"input": "4 -2 -2 4\n 3\n 0 0 2\n 4 0 1\n 0 4 1", "output": "4.0000000000\n \n\nAn optimal route is as follows:\n\n![d09006720c225cbe69eae3fd9c186e67.png](https://atcoder.jp/img/arc064/d09006720c225cbe69eae3fd9c186e67.png)"}]
Print the minimum possible duration of time Snuke is exposed to cosmic rays during the travel. The output is considered correct if the absolute or relative error is at most 10^{-9}. * * *
s692044917
Accepted
p03866
The input is given from Standard Input in the following format: x_s y_s x_t y_t N x_1 y_1 r_1 x_2 y_2 r_2 : x_N y_N r_N
class Dijkstra: class Edge: # weighted directed edge def __init__(self, _to, _cost): self.to = _to self.cost = _cost def __init__(self, V): # 0-indexed self.G = [[] for i in range(V)] self._E = 0 self._V = V def E(self): # number of edge return self._E def V(self): # number of vertex return self._V def add(self, _from, _to, _cost): # add vertex and edge cost self.G[_from].append(self.Edge(_to, _cost)) self._E += 1 def shortest_path(self, s): # return the list of shortest pathes from s to each vertex import heapq que = [] d = [float("inf")] * self._V d[s] = 0 heapq.heappush(que, (0, s)) while que: cost, v = heapq.heappop(que) if d[v] < cost: continue for i in range(len(self.G[v])): e = self.G[v][i] if d[e.to] > d[v] + e.cost: d[e.to] = d[v] + e.cost heapq.heappush(que, (d[e.to], e.to)) return d import sys input = sys.stdin.readline xs, ys, xt, yt = map(int, input().split()) n = int(input()) xyr = [list(map(int, input().split())) for i in range(n)] graph = [[10**9] * (n + 2) for i in range(n + 2)] graph[0][n + 1] = graph[n + 1][0] = ((xs - xt) ** 2 + (ys - yt) ** 2) ** 0.5 for i in range(1, n + 1): for j in range(1, n + 1): d = ( (xyr[i - 1][0] - xyr[j - 1][0]) ** 2 + (xyr[i - 1][1] - xyr[j - 1][1]) ** 2 ) ** 0.5 graph[i][j] = graph[j][i] = max(0, d - xyr[i - 1][2] - xyr[j - 1][2]) for i in range(1, n + 1): d1 = ((xs - xyr[i - 1][0]) ** 2 + (ys - xyr[i - 1][1]) ** 2) ** 0.5 d2 = ((xt - xyr[i - 1][0]) ** 2 + (yt - xyr[i - 1][1]) ** 2) ** 0.5 graph[0][i] = graph[i][0] = max(0, d1 - xyr[i - 1][2]) graph[n + 1][i] = graph[i][n + 1] = max(0, d2 - xyr[i - 1][2]) d = Dijkstra(n + 2) for i in range(n + 2): for j in range(n + 2): d.add(i, j, graph[i][j]) print(d.shortest_path(0)[n + 1])
Statement On the xy-plane, Snuke is going to travel from the point (x_s, y_s) to the point (x_t, y_t). He can move in arbitrary directions with speed 1. Here, we will consider him as a point without size. There are N circular barriers deployed on the plane. The center and the radius of the i-th barrier are (x_i, y_i) and r_i, respectively. The barriers may overlap or contain each other. A point on the plane is exposed to cosmic rays if the point is not within any of the barriers. Snuke wants to avoid exposure to cosmic rays as much as possible during the travel. Find the minimum possible duration of time he is exposed to cosmic rays during the travel.
[{"input": "-2 -2 2 2\n 1\n 0 0 1", "output": "3.6568542495\n \n\nAn optimal route is as follows:\n\n![e9c630751968b7051df5750b7ddc0e07.png](https://atcoder.jp/img/arc064/e9c630751968b7051df5750b7ddc0e07.png)\n\n* * *"}, {"input": "-2 0 2 0\n 2\n -1 0 2\n 1 0 2", "output": "0.0000000000\n \n\nAn optimal route is as follows:\n\n![fb82f6f4df5b22cffb868ce6333277aa.png](https://atcoder.jp/img/arc064/fb82f6f4df5b22cffb868ce6333277aa.png)\n\n* * *"}, {"input": "4 -2 -2 4\n 3\n 0 0 2\n 4 0 1\n 0 4 1", "output": "4.0000000000\n \n\nAn optimal route is as follows:\n\n![d09006720c225cbe69eae3fd9c186e67.png](https://atcoder.jp/img/arc064/d09006720c225cbe69eae3fd9c186e67.png)"}]
Print the minimum possible duration of time Snuke is exposed to cosmic rays during the travel. The output is considered correct if the absolute or relative error is at most 10^{-9}. * * *
s227484216
Accepted
p03866
The input is given from Standard Input in the following format: x_s y_s x_t y_t N x_1 y_1 r_1 x_2 y_2 r_2 : x_N y_N r_N
import sys stdin = sys.stdin sys.setrecursionlimit(10**5) def li(): return map(int, stdin.readline().split()) def li_(): return map(lambda x: int(x) - 1, stdin.readline().split()) def lf(): return map(float, stdin.readline().split()) def ls(): return stdin.readline().split() def ns(): return stdin.readline().rstrip() def lc(): return list(ns()) def ni(): return int(stdin.readline()) def nf(): return float(stdin.readline()) from math import sqrt from heapq import heappush, heappop # node class class Node(object): def __init__(self, num, x, y, r): self.num = num self.x = x self.y = y self.r = r # graph class class Graph(object): def __init__(self, num): self.graph = [[] for _ in range(num)] self.nodes = [] # 辺の長さを調べる def calc_edge_len(self, node1, node2): dist = ( sqrt((node1.x - node2.x) ** 2 + (node1.y - node2.y) ** 2) - node1.r - node2.r ) if dist <= 0: return 0 else: return dist # 辺を追加する def add_edge(self, node1, node2): edge_len = self.calc_edge_len(node1, node2) self.graph[node1.num].append((edge_len, node2.num)) self.graph[node2.num].append((edge_len, node1.num)) def get_graph(self): return self.graph # ダイクストラ法 def dijkstra(graph: list, node: int, start: int, goal: int) -> int: # 未探索のノードは距離INF INF = float("inf") dist = [INF] * node # 始点ノードの距離を0とし、dfsのためのpriority queを作成 dist[start] = 0 heap = [(0, start)] visited = [False] * node # 未探索のノードをpriority queueに入れる while heap: cost, cur_node = heappop(heap) if visited[cur_node]: continue visited[cur_node] = True if cur_node == goal: return dist[goal] for nex_cost, nex_node in graph[cur_node]: dist_cand = dist[cur_node] + nex_cost if dist_cand < dist[nex_node]: dist[nex_node] = dist_cand heappush(heap, (dist[nex_node], nex_node)) return dist[goal] # input xs, ys, xt, yt = li() n = ni() # グラフにスタートとゴールを追加 g = Graph(n + 2) g.nodes.append(Node(0, xs, ys, 0)) g.nodes.append(Node(1, xt, yt, 0)) # グラフにそれぞれのバリアを追加 for i in range(n): x, y, r = li() g.nodes.append(Node(i + 2, x, y, r)) # バリアを結ぶエッジを追加していく for i in range(len(g.nodes)): for j in range(i + 1, len(g.nodes)): g.add_edge(g.nodes[i], g.nodes[j]) graph = g.get_graph() # 隣接リストをダイクストラに放り込む dist = dijkstra(graph, n + 2, 0, 1) print(dist)
Statement On the xy-plane, Snuke is going to travel from the point (x_s, y_s) to the point (x_t, y_t). He can move in arbitrary directions with speed 1. Here, we will consider him as a point without size. There are N circular barriers deployed on the plane. The center and the radius of the i-th barrier are (x_i, y_i) and r_i, respectively. The barriers may overlap or contain each other. A point on the plane is exposed to cosmic rays if the point is not within any of the barriers. Snuke wants to avoid exposure to cosmic rays as much as possible during the travel. Find the minimum possible duration of time he is exposed to cosmic rays during the travel.
[{"input": "-2 -2 2 2\n 1\n 0 0 1", "output": "3.6568542495\n \n\nAn optimal route is as follows:\n\n![e9c630751968b7051df5750b7ddc0e07.png](https://atcoder.jp/img/arc064/e9c630751968b7051df5750b7ddc0e07.png)\n\n* * *"}, {"input": "-2 0 2 0\n 2\n -1 0 2\n 1 0 2", "output": "0.0000000000\n \n\nAn optimal route is as follows:\n\n![fb82f6f4df5b22cffb868ce6333277aa.png](https://atcoder.jp/img/arc064/fb82f6f4df5b22cffb868ce6333277aa.png)\n\n* * *"}, {"input": "4 -2 -2 4\n 3\n 0 0 2\n 4 0 1\n 0 4 1", "output": "4.0000000000\n \n\nAn optimal route is as follows:\n\n![d09006720c225cbe69eae3fd9c186e67.png](https://atcoder.jp/img/arc064/d09006720c225cbe69eae3fd9c186e67.png)"}]
Print the shortest distance in a line.
s527187946
Wrong Answer
p02324
|V| |E| s0 t0 d0 s1 t1 d1 : s|E|-1 t|E|-1 d|E|-1 , where |V| is the number of vertices and |E| is the number of edges in the graph. The graph vertices are named with the numbers 0, 1,..., |V|-1 respectively. si and ti represent source and target verticess of i-th edge (undirected) and di represents the distance between si and ti (the i-th edge). Note that there can be multiple edges between a pair of vertices.
def warshall_floyd(n, links): prev = [t.copy() for t in links] for i in range(n): prev[i][i] = 0 for k in range(n - 1): current = [t.copy() for t in prev] prev_k = prev[k] for i in range(n): prev_i, current_i = prev[i], current[i] prev_i_k = prev_i[k] for j in range(n): current_i[j] = min(prev_i[j], prev_i_k + prev_k[j]) prev = current return prev def solve(n, links, total_d, odd_vertices): if not odd_vertices: return total_d d_table = warshall_floyd(n, links) d_table = [[d for oj, d in enumerate(d_table[oi]) if oj in odd_vertices] for ni, oi in enumerate(odd_vertices)] ndt = len(d_table) bit_dict = {1 << i: i for i in range(ndt)} def minimum_pair(remains): if not remains: return 0 b = remains & -remains remains ^= b i = bit_dict[b] return min(minimum_pair(remains ^ (1 << j)) + d_table[i][j] for j in range(ndt) if remains & (1 << j)) return total_d + minimum_pair((1 << ndt) - 1) v, e = map(int, input().split()) links = [[float('inf')] * v for _ in range(v)] odd_vertices = [0] * v total_d = 0 for _ in range(e): s, t, d = map(int, input().split()) links[s][t] = min(links[s][t], d) links[t][s] = min(links[t][s], d) odd_vertices[s] ^= 1 odd_vertices[t] ^= 1 total_d += d print(solve(v, links, total_d, [i for i, v in enumerate(odd_vertices) if v]))
Chinese Postman Problem For a given weighted undirected graph G(V, E), find the distance of the shortest route that meets the following criteria: * It is a closed cycle where it ends at the same point it starts. * The route must go through every edge at least once.
[{"input": "4 4\n 0 1 1\n 0 2 2\n 1 3 3\n 2 3 4", "output": "10"}, {"input": "4 5\n 0 1 1\n 0 2 2\n 1 3 3\n 2 3 4\n 1 2 5", "output": "18"}, {"input": "2 3\n 0 1 1\n 0 1 2\n 0 1 3", "output": "7"}]
Print `YES` if the arrangement of the poles is beautiful; print `NO` otherwise. * * *
s904779673
Accepted
p03759
Input is given from Standard Input in the following format: a b c
# region header import sys import math from bisect import bisect_left, bisect_right, insort_left, insort_right from collections import defaultdict, deque, Counter from copy import deepcopy from fractions import gcd from functools import lru_cache, reduce from heapq import heappop, heappush from itertools import ( accumulate, groupby, product, permutations, combinations, combinations_with_replacement, ) from math import ceil, floor, factorial, log, sqrt, sin, cos from operator import itemgetter from string import ascii_lowercase, ascii_uppercase, digits sys.setrecursionlimit(10**6) INF = float("inf") MOD = 10**9 + 7 def rs(): return sys.stdin.readline().rstrip() def ri(): return int(rs()) def rf(): return float(rs()) def rs_(): return [_ for _ in rs().split()] def ri_(): return [int(_) for _ in rs().split()] def rf_(): return [float(_) for _ in rs().split()] def divisors(n, sortedresult=True): div = [] for i in range(1, int(n**0.5) + 1): if n % i == 0: div.append(i) if i != n // i: div.append(n // i) if sortedresult: div.sort() return div # endregion a, b, c = ri_() print("YES" if b - a == c - b else "NO")
Statement Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
[{"input": "2 4 6", "output": "YES\n \n\nSince 4-2 = 6-4, this arrangement of poles is beautiful.\n\n* * *"}, {"input": "2 5 6", "output": "NO\n \n\nSince 5-2 \\neq 6-5, this arrangement of poles is not beautiful.\n\n* * *"}, {"input": "3 2 1", "output": "YES\n \n\nSince 1-2 = 2-3, this arrangement of poles is beautiful."}]
Print `YES` if the arrangement of the poles is beautiful; print `NO` otherwise. * * *
s156356900
Accepted
p03759
Input is given from Standard Input in the following format: a b c
#!/usr/bin/env python3 import sys # import time # import math # import numpy as np # import scipy.sparse.csgraph as cs # csgraph_from_dense(ndarray, null_value=inf), bellman_ford(G, return_predecessors=True), dijkstra, floyd_warshall # import random # random, uniform, randint, randrange, shuffle, sample # import string # ascii_lowercase, ascii_uppercase, ascii_letters, digits, hexdigits # import re # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s) # from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]). # from collections import deque # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate() # from collections import defaultdict # subclass of dict. defaultdict(facroty) # from collections import Counter # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter) # from datetime import date, datetime # date.today(), date(year,month,day) => date obj; datetime.now(), datetime(year,month,day,hour,second,microsecond) => datetime obj; subtraction => timedelta obj # from datetime.datetime import strptime # strptime('2019/01/01 10:05:20', '%Y/%m/%d/ %H:%M:%S') returns datetime obj # from datetime import timedelta # td.days, td.seconds, td.microseconds, td.total_seconds(). abs function is also available. # from copy import copy, deepcopy # use deepcopy to copy multi-dimentional matrix without reference # from functools import reduce # reduce(f, iter[, init]) # from functools import lru_cache # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed) # from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn). # from heapq import nlargest, nsmallest # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn). # from itertools import count, cycle, repeat # count(start[,step]), cycle(iter), repeat(elm[,n]) # from itertools import groupby # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])] # from itertools import starmap # starmap(pow, [[2,5], [3,2]]) returns [32, 9] # from itertools import product, permutations # product(iter, repeat=n), permutations(iter[,r]) # from itertools import combinations, combinations_with_replacement # from itertools import accumulate # accumulate(iter[, f]) # from operator import itemgetter # itemgetter(1), itemgetter('key') # from fractions import gcd # for Python 3.4 (previous contest @AtCoder) def main(): mod = 1000000007 # 10^9+7 inf = float("inf") # sys.float_info.max = 1.79...e+308 # inf = 2 ** 64 - 1 # (for fast JIT compile in PyPy) 1.84...e+19 sys.setrecursionlimit(10**6) # 1000 -> 1000000 def input(): return sys.stdin.readline().rstrip() def ii(): return int(input()) def mi(): return map(int, input().split()) def mi_0(): return map(lambda x: int(x) - 1, input().split()) def lmi(): return list(map(int, input().split())) def lmi_0(): return list(map(lambda x: int(x) - 1, input().split())) def li(): return list(input()) a, b, c = mi() print("YES") if b - a == c - b else print("NO") if __name__ == "__main__": main()
Statement Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
[{"input": "2 4 6", "output": "YES\n \n\nSince 4-2 = 6-4, this arrangement of poles is beautiful.\n\n* * *"}, {"input": "2 5 6", "output": "NO\n \n\nSince 5-2 \\neq 6-5, this arrangement of poles is not beautiful.\n\n* * *"}, {"input": "3 2 1", "output": "YES\n \n\nSince 1-2 = 2-3, this arrangement of poles is beautiful."}]
Print `YES` if the arrangement of the poles is beautiful; print `NO` otherwise. * * *
s574748939
Runtime Error
p03759
Input is given from Standard Input in the following format: a b c
def ntukusi(a,b,c): ans = "YES" if b - a = c - b else "NO" return ans def main(): a , b , c = map(int, input().split()) print(ntukusi(a , b , c)) if __name__ == '__main__': main()
Statement Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
[{"input": "2 4 6", "output": "YES\n \n\nSince 4-2 = 6-4, this arrangement of poles is beautiful.\n\n* * *"}, {"input": "2 5 6", "output": "NO\n \n\nSince 5-2 \\neq 6-5, this arrangement of poles is not beautiful.\n\n* * *"}, {"input": "3 2 1", "output": "YES\n \n\nSince 1-2 = 2-3, this arrangement of poles is beautiful."}]
Print `YES` if the arrangement of the poles is beautiful; print `NO` otherwise. * * *
s785769357
Runtime Error
p03759
Input is given from Standard Input in the following format: a b c
N, T = map(int, input().split()) A = list(map(int, input().split())) tot = 0 for i in range(1, N): d = A[i] - A[i - 1] if d > T: tot += T else: tot += d print(tot + T)
Statement Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
[{"input": "2 4 6", "output": "YES\n \n\nSince 4-2 = 6-4, this arrangement of poles is beautiful.\n\n* * *"}, {"input": "2 5 6", "output": "NO\n \n\nSince 5-2 \\neq 6-5, this arrangement of poles is not beautiful.\n\n* * *"}, {"input": "3 2 1", "output": "YES\n \n\nSince 1-2 = 2-3, this arrangement of poles is beautiful."}]
Print `YES` if the arrangement of the poles is beautiful; print `NO` otherwise. * * *
s998935692
Runtime Error
p03759
Input is given from Standard Input in the following format: a b c
def ntukusi(a,b,c): return "YES" if b - a = c - b else "NO" def main(): a , b , c = map(int, input().split()) print(ntukusi(a , b , c)) if __name__ == '__main__': main()
Statement Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
[{"input": "2 4 6", "output": "YES\n \n\nSince 4-2 = 6-4, this arrangement of poles is beautiful.\n\n* * *"}, {"input": "2 5 6", "output": "NO\n \n\nSince 5-2 \\neq 6-5, this arrangement of poles is not beautiful.\n\n* * *"}, {"input": "3 2 1", "output": "YES\n \n\nSince 1-2 = 2-3, this arrangement of poles is beautiful."}]
Print `YES` if the arrangement of the poles is beautiful; print `NO` otherwise. * * *
s063097130
Runtime Error
p03759
Input is given from Standard Input in the following format: a b c
a,b,c = map(int,input().split()) if (b-a)==(c-b): print("YES") else: print("NO")a,b,c = map(int,input().split())
Statement Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
[{"input": "2 4 6", "output": "YES\n \n\nSince 4-2 = 6-4, this arrangement of poles is beautiful.\n\n* * *"}, {"input": "2 5 6", "output": "NO\n \n\nSince 5-2 \\neq 6-5, this arrangement of poles is not beautiful.\n\n* * *"}, {"input": "3 2 1", "output": "YES\n \n\nSince 1-2 = 2-3, this arrangement of poles is beautiful."}]
Print `YES` if the arrangement of the poles is beautiful; print `NO` otherwise. * * *
s826237806
Wrong Answer
p03759
Input is given from Standard Input in the following format: a b c
print("YES")
Statement Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
[{"input": "2 4 6", "output": "YES\n \n\nSince 4-2 = 6-4, this arrangement of poles is beautiful.\n\n* * *"}, {"input": "2 5 6", "output": "NO\n \n\nSince 5-2 \\neq 6-5, this arrangement of poles is not beautiful.\n\n* * *"}, {"input": "3 2 1", "output": "YES\n \n\nSince 1-2 = 2-3, this arrangement of poles is beautiful."}]
Print `YES` if the arrangement of the poles is beautiful; print `NO` otherwise. * * *
s976540730
Runtime Error
p03759
Input is given from Standard Input in the following format: a b c
a, b, c = map(int, input().split()) r = 'YES' if b - a == c - b else 'N
Statement Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
[{"input": "2 4 6", "output": "YES\n \n\nSince 4-2 = 6-4, this arrangement of poles is beautiful.\n\n* * *"}, {"input": "2 5 6", "output": "NO\n \n\nSince 5-2 \\neq 6-5, this arrangement of poles is not beautiful.\n\n* * *"}, {"input": "3 2 1", "output": "YES\n \n\nSince 1-2 = 2-3, this arrangement of poles is beautiful."}]
Print `YES` if the arrangement of the poles is beautiful; print `NO` otherwise. * * *
s412169818
Runtime Error
p03759
Input is given from Standard Input in the following format: a b c
a,b,c=map(int, input().split()) print("YES" if b-a=c-b else "NO")
Statement Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
[{"input": "2 4 6", "output": "YES\n \n\nSince 4-2 = 6-4, this arrangement of poles is beautiful.\n\n* * *"}, {"input": "2 5 6", "output": "NO\n \n\nSince 5-2 \\neq 6-5, this arrangement of poles is not beautiful.\n\n* * *"}, {"input": "3 2 1", "output": "YES\n \n\nSince 1-2 = 2-3, this arrangement of poles is beautiful."}]
Print `YES` if the arrangement of the poles is beautiful; print `NO` otherwise. * * *
s848797160
Runtime Error
p03759
Input is given from Standard Input in the following format: a b c
a, b = input().split() print("H" if (a == "H") ^ (b == "D") else "D")
Statement Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
[{"input": "2 4 6", "output": "YES\n \n\nSince 4-2 = 6-4, this arrangement of poles is beautiful.\n\n* * *"}, {"input": "2 5 6", "output": "NO\n \n\nSince 5-2 \\neq 6-5, this arrangement of poles is not beautiful.\n\n* * *"}, {"input": "3 2 1", "output": "YES\n \n\nSince 1-2 = 2-3, this arrangement of poles is beautiful."}]
Print `YES` if the arrangement of the poles is beautiful; print `NO` otherwise. * * *
s575488550
Runtime Error
p03759
Input is given from Standard Input in the following format: a b c
a,b,c=map(int,input().split()) if b-a=c-b: print("YES") else: print("NO")
Statement Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
[{"input": "2 4 6", "output": "YES\n \n\nSince 4-2 = 6-4, this arrangement of poles is beautiful.\n\n* * *"}, {"input": "2 5 6", "output": "NO\n \n\nSince 5-2 \\neq 6-5, this arrangement of poles is not beautiful.\n\n* * *"}, {"input": "3 2 1", "output": "YES\n \n\nSince 1-2 = 2-3, this arrangement of poles is beautiful."}]
Print `YES` if the arrangement of the poles is beautiful; print `NO` otherwise. * * *
s199881248
Accepted
p03759
Input is given from Standard Input in the following format: a b c
f = lambda x: x[0] - 2 * x[1] + x[2] == 0 print("YES" if f(list(map(int, input().split()))) else "NO")
Statement Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
[{"input": "2 4 6", "output": "YES\n \n\nSince 4-2 = 6-4, this arrangement of poles is beautiful.\n\n* * *"}, {"input": "2 5 6", "output": "NO\n \n\nSince 5-2 \\neq 6-5, this arrangement of poles is not beautiful.\n\n* * *"}, {"input": "3 2 1", "output": "YES\n \n\nSince 1-2 = 2-3, this arrangement of poles is beautiful."}]
Print `YES` if the arrangement of the poles is beautiful; print `NO` otherwise. * * *
s097213047
Runtime Error
p03759
Input is given from Standard Input in the following format: a b c
a=list(map(int,input().split())) if a[0]+a[2]=2*a[1]: print('YES') else: print('NO')
Statement Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
[{"input": "2 4 6", "output": "YES\n \n\nSince 4-2 = 6-4, this arrangement of poles is beautiful.\n\n* * *"}, {"input": "2 5 6", "output": "NO\n \n\nSince 5-2 \\neq 6-5, this arrangement of poles is not beautiful.\n\n* * *"}, {"input": "3 2 1", "output": "YES\n \n\nSince 1-2 = 2-3, this arrangement of poles is beautiful."}]
Print `YES` if the arrangement of the poles is beautiful; print `NO` otherwise. * * *
s258905080
Runtime Error
p03759
Input is given from Standard Input in the following format: a b c
a, b, c = map(int, input().split().split()) if b−a==c−b: print ("YES") elif print("NO")
Statement Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
[{"input": "2 4 6", "output": "YES\n \n\nSince 4-2 = 6-4, this arrangement of poles is beautiful.\n\n* * *"}, {"input": "2 5 6", "output": "NO\n \n\nSince 5-2 \\neq 6-5, this arrangement of poles is not beautiful.\n\n* * *"}, {"input": "3 2 1", "output": "YES\n \n\nSince 1-2 = 2-3, this arrangement of poles is beautiful."}]
Print `YES` if the arrangement of the poles is beautiful; print `NO` otherwise. * * *
s239874816
Runtime Error
p03759
Input is given from Standard Input in the following format: a b c
a, b, c = [int(x) for x in input().split()] if b−a == c−b: print("YES") else: print("NO")
Statement Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
[{"input": "2 4 6", "output": "YES\n \n\nSince 4-2 = 6-4, this arrangement of poles is beautiful.\n\n* * *"}, {"input": "2 5 6", "output": "NO\n \n\nSince 5-2 \\neq 6-5, this arrangement of poles is not beautiful.\n\n* * *"}, {"input": "3 2 1", "output": "YES\n \n\nSince 1-2 = 2-3, this arrangement of poles is beautiful."}]
Print `YES` if the arrangement of the poles is beautiful; print `NO` otherwise. * * *
s957815249
Runtime Error
p03759
Input is given from Standard Input in the following format: a b c
a,b,c = map(int,input().split()) if b - a = c - b: print("YES") else: print("NO")
Statement Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
[{"input": "2 4 6", "output": "YES\n \n\nSince 4-2 = 6-4, this arrangement of poles is beautiful.\n\n* * *"}, {"input": "2 5 6", "output": "NO\n \n\nSince 5-2 \\neq 6-5, this arrangement of poles is not beautiful.\n\n* * *"}, {"input": "3 2 1", "output": "YES\n \n\nSince 1-2 = 2-3, this arrangement of poles is beautiful."}]
Print `YES` if the arrangement of the poles is beautiful; print `NO` otherwise. * * *
s454791792
Runtime Error
p03759
Input is given from Standard Input in the following format: a b c
a,b,c=map(int,input().split()) if a-b = b-c: print("YES") else: print("NO")
Statement Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
[{"input": "2 4 6", "output": "YES\n \n\nSince 4-2 = 6-4, this arrangement of poles is beautiful.\n\n* * *"}, {"input": "2 5 6", "output": "NO\n \n\nSince 5-2 \\neq 6-5, this arrangement of poles is not beautiful.\n\n* * *"}, {"input": "3 2 1", "output": "YES\n \n\nSince 1-2 = 2-3, this arrangement of poles is beautiful."}]
Print `YES` if the arrangement of the poles is beautiful; print `NO` otherwise. * * *
s349521755
Runtime Error
p03759
Input is given from Standard Input in the following format: a b c
a, b, c = map(int, input().split()) if b−a == c−b: print("YES") else: print("NO")
Statement Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
[{"input": "2 4 6", "output": "YES\n \n\nSince 4-2 = 6-4, this arrangement of poles is beautiful.\n\n* * *"}, {"input": "2 5 6", "output": "NO\n \n\nSince 5-2 \\neq 6-5, this arrangement of poles is not beautiful.\n\n* * *"}, {"input": "3 2 1", "output": "YES\n \n\nSince 1-2 = 2-3, this arrangement of poles is beautiful."}]
Print `YES` if the arrangement of the poles is beautiful; print `NO` otherwise. * * *
s564877121
Runtime Error
p03759
Input is given from Standard Input in the following format: a b c
#58 a,b,c=map(int,input().split()) if b-a=c-b: print('Yes') else: print('No')
Statement Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
[{"input": "2 4 6", "output": "YES\n \n\nSince 4-2 = 6-4, this arrangement of poles is beautiful.\n\n* * *"}, {"input": "2 5 6", "output": "NO\n \n\nSince 5-2 \\neq 6-5, this arrangement of poles is not beautiful.\n\n* * *"}, {"input": "3 2 1", "output": "YES\n \n\nSince 1-2 = 2-3, this arrangement of poles is beautiful."}]
Print `YES` if the arrangement of the poles is beautiful; print `NO` otherwise. * * *
s806635946
Runtime Error
p03759
Input is given from Standard Input in the following format: a b c
a, b, c = map(int, input()split()) if b - a == c - b: print("YES") else: print("NO")
Statement Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
[{"input": "2 4 6", "output": "YES\n \n\nSince 4-2 = 6-4, this arrangement of poles is beautiful.\n\n* * *"}, {"input": "2 5 6", "output": "NO\n \n\nSince 5-2 \\neq 6-5, this arrangement of poles is not beautiful.\n\n* * *"}, {"input": "3 2 1", "output": "YES\n \n\nSince 1-2 = 2-3, this arrangement of poles is beautiful."}]
Print `YES` if the arrangement of the poles is beautiful; print `NO` otherwise. * * *
s770552987
Runtime Error
p03759
Input is given from Standard Input in the following format: a b c
a = list(input()) b = list(input()) + [""] for c, d in zip(a, b): print(c + d, end="")
Statement Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
[{"input": "2 4 6", "output": "YES\n \n\nSince 4-2 = 6-4, this arrangement of poles is beautiful.\n\n* * *"}, {"input": "2 5 6", "output": "NO\n \n\nSince 5-2 \\neq 6-5, this arrangement of poles is not beautiful.\n\n* * *"}, {"input": "3 2 1", "output": "YES\n \n\nSince 1-2 = 2-3, this arrangement of poles is beautiful."}]
Print `YES` if the arrangement of the poles is beautiful; print `NO` otherwise. * * *
s075716596
Runtime Error
p03759
Input is given from Standard Input in the following format: a b c
a, b, c = = map(int,input().split()) print('YES') if a == b == c else print('NO')
Statement Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
[{"input": "2 4 6", "output": "YES\n \n\nSince 4-2 = 6-4, this arrangement of poles is beautiful.\n\n* * *"}, {"input": "2 5 6", "output": "NO\n \n\nSince 5-2 \\neq 6-5, this arrangement of poles is not beautiful.\n\n* * *"}, {"input": "3 2 1", "output": "YES\n \n\nSince 1-2 = 2-3, this arrangement of poles is beautiful."}]
Print `YES` if the arrangement of the poles is beautiful; print `NO` otherwise. * * *
s682555770
Runtime Error
p03759
Input is given from Standard Input in the following format: a b c
#58 a,b,c=map(int,input().split()) if b-a=c-b: print('YES') else: print('NO')
Statement Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
[{"input": "2 4 6", "output": "YES\n \n\nSince 4-2 = 6-4, this arrangement of poles is beautiful.\n\n* * *"}, {"input": "2 5 6", "output": "NO\n \n\nSince 5-2 \\neq 6-5, this arrangement of poles is not beautiful.\n\n* * *"}, {"input": "3 2 1", "output": "YES\n \n\nSince 1-2 = 2-3, this arrangement of poles is beautiful."}]
Print `YES` if the arrangement of the poles is beautiful; print `NO` otherwise. * * *
s032611672
Runtime Error
p03759
Input is given from Standard Input in the following format: a b c
a,b,c = map(int,input().split()) if 2*b = a+c: print("YES") else: print("NO")
Statement Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
[{"input": "2 4 6", "output": "YES\n \n\nSince 4-2 = 6-4, this arrangement of poles is beautiful.\n\n* * *"}, {"input": "2 5 6", "output": "NO\n \n\nSince 5-2 \\neq 6-5, this arrangement of poles is not beautiful.\n\n* * *"}, {"input": "3 2 1", "output": "YES\n \n\nSince 1-2 = 2-3, this arrangement of poles is beautiful."}]
Print `YES` if the arrangement of the poles is beautiful; print `NO` otherwise. * * *
s915207751
Runtime Error
p03759
Input is given from Standard Input in the following format: a b c
if a-b == b-c: print('YES') if a-b =! b-c: print('NO')
Statement Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
[{"input": "2 4 6", "output": "YES\n \n\nSince 4-2 = 6-4, this arrangement of poles is beautiful.\n\n* * *"}, {"input": "2 5 6", "output": "NO\n \n\nSince 5-2 \\neq 6-5, this arrangement of poles is not beautiful.\n\n* * *"}, {"input": "3 2 1", "output": "YES\n \n\nSince 1-2 = 2-3, this arrangement of poles is beautiful."}]
Print `YES` if the arrangement of the poles is beautiful; print `NO` otherwise. * * *
s226339189
Runtime Error
p03759
Input is given from Standard Input in the following format: a b c
a, b, c = map(int, input().split().split()) if b−a == c−b: print("YES") else: print("NO")
Statement Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
[{"input": "2 4 6", "output": "YES\n \n\nSince 4-2 = 6-4, this arrangement of poles is beautiful.\n\n* * *"}, {"input": "2 5 6", "output": "NO\n \n\nSince 5-2 \\neq 6-5, this arrangement of poles is not beautiful.\n\n* * *"}, {"input": "3 2 1", "output": "YES\n \n\nSince 1-2 = 2-3, this arrangement of poles is beautiful."}]
Print `YES` if the arrangement of the poles is beautiful; print `NO` otherwise. * * *
s442694348
Runtime Error
p03759
Input is given from Standard Input in the following format: a b c
def beautiful: a = int(input()) b = int(input()) c = int(input()) if ((abs(b-a)) == (abs(c-b))): print('YES') else: print('NO') beautiful()
Statement Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
[{"input": "2 4 6", "output": "YES\n \n\nSince 4-2 = 6-4, this arrangement of poles is beautiful.\n\n* * *"}, {"input": "2 5 6", "output": "NO\n \n\nSince 5-2 \\neq 6-5, this arrangement of poles is not beautiful.\n\n* * *"}, {"input": "3 2 1", "output": "YES\n \n\nSince 1-2 = 2-3, this arrangement of poles is beautiful."}]
Print `YES` if the arrangement of the poles is beautiful; print `NO` otherwise. * * *
s479890419
Runtime Error
p03759
Input is given from Standard Input in the following format: a b c
a, b, c = map(int, input().split().split()) if b−a == c−b: print("YES") else: print("NO")
Statement Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
[{"input": "2 4 6", "output": "YES\n \n\nSince 4-2 = 6-4, this arrangement of poles is beautiful.\n\n* * *"}, {"input": "2 5 6", "output": "NO\n \n\nSince 5-2 \\neq 6-5, this arrangement of poles is not beautiful.\n\n* * *"}, {"input": "3 2 1", "output": "YES\n \n\nSince 1-2 = 2-3, this arrangement of poles is beautiful."}]
Print `YES` if the arrangement of the poles is beautiful; print `NO` otherwise. * * *
s416350032
Runtime Error
p03759
Input is given from Standard Input in the following format: a b c
O = list(input()) E = list(input()) s = "" while O or E: if len(E) >= len(O): s = E.pop() + s else: s = O.pop() + s print(s)
Statement Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
[{"input": "2 4 6", "output": "YES\n \n\nSince 4-2 = 6-4, this arrangement of poles is beautiful.\n\n* * *"}, {"input": "2 5 6", "output": "NO\n \n\nSince 5-2 \\neq 6-5, this arrangement of poles is not beautiful.\n\n* * *"}, {"input": "3 2 1", "output": "YES\n \n\nSince 1-2 = 2-3, this arrangement of poles is beautiful."}]
Print `YES` if the arrangement of the poles is beautiful; print `NO` otherwise. * * *
s243715984
Runtime Error
p03759
Input is given from Standard Input in the following format: a b c
a,b,c=input().split() a1=int(a) b1=int(b) c1=int(c) d=b1-a1 e=c1-b1 if d==e: print('YES') else : print('NO')a,b,c=input().split()
Statement Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
[{"input": "2 4 6", "output": "YES\n \n\nSince 4-2 = 6-4, this arrangement of poles is beautiful.\n\n* * *"}, {"input": "2 5 6", "output": "NO\n \n\nSince 5-2 \\neq 6-5, this arrangement of poles is not beautiful.\n\n* * *"}, {"input": "3 2 1", "output": "YES\n \n\nSince 1-2 = 2-3, this arrangement of poles is beautiful."}]
Print `YES` if the arrangement of the poles is beautiful; print `NO` otherwise. * * *
s711929408
Runtime Error
p03759
Input is given from Standard Input in the following format: a b c
num = list(map(int, input().split())) if(b-a = c-b): print('Yes') a = num[0] + num[1] print(int(a/24))
Statement Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
[{"input": "2 4 6", "output": "YES\n \n\nSince 4-2 = 6-4, this arrangement of poles is beautiful.\n\n* * *"}, {"input": "2 5 6", "output": "NO\n \n\nSince 5-2 \\neq 6-5, this arrangement of poles is not beautiful.\n\n* * *"}, {"input": "3 2 1", "output": "YES\n \n\nSince 1-2 = 2-3, this arrangement of poles is beautiful."}]
Print `YES` if the arrangement of the poles is beautiful; print `NO` otherwise. * * *
s059651328
Runtime Error
p03759
Input is given from Standard Input in the following format: a b c
# -*- coding: utf-8 -*- a,b,c = [int(i) for i in input().split()] if 1 <= a and b and c m<= 100: if b - a == c - b: print("YES") else: print("NO")
Statement Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
[{"input": "2 4 6", "output": "YES\n \n\nSince 4-2 = 6-4, this arrangement of poles is beautiful.\n\n* * *"}, {"input": "2 5 6", "output": "NO\n \n\nSince 5-2 \\neq 6-5, this arrangement of poles is not beautiful.\n\n* * *"}, {"input": "3 2 1", "output": "YES\n \n\nSince 1-2 = 2-3, this arrangement of poles is beautiful."}]
Print `YES` if the arrangement of the poles is beautiful; print `NO` otherwise. * * *
s042255981
Runtime Error
p03759
Input is given from Standard Input in the following format: a b c
O = [] O = input().split() LO = int(len(O)) E = input().split() LE = len(E) flist = [] for i in range(LO): if i > LE: a = O[i] flist.append(a) else: a = O[i] + E[i] flist.append(a) print("".join(flist))
Statement Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
[{"input": "2 4 6", "output": "YES\n \n\nSince 4-2 = 6-4, this arrangement of poles is beautiful.\n\n* * *"}, {"input": "2 5 6", "output": "NO\n \n\nSince 5-2 \\neq 6-5, this arrangement of poles is not beautiful.\n\n* * *"}, {"input": "3 2 1", "output": "YES\n \n\nSince 1-2 = 2-3, this arrangement of poles is beautiful."}]
Print `YES` if the arrangement of the poles is beautiful; print `NO` otherwise. * * *
s290628378
Runtime Error
p03759
Input is given from Standard Input in the following format: a b c
;
Statement Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
[{"input": "2 4 6", "output": "YES\n \n\nSince 4-2 = 6-4, this arrangement of poles is beautiful.\n\n* * *"}, {"input": "2 5 6", "output": "NO\n \n\nSince 5-2 \\neq 6-5, this arrangement of poles is not beautiful.\n\n* * *"}, {"input": "3 2 1", "output": "YES\n \n\nSince 1-2 = 2-3, this arrangement of poles is beautiful."}]
Print `YES` if the arrangement of the poles is beautiful; print `NO` otherwise. * * *
s914715107
Runtime Error
p03759
Input is given from Standard Input in the following format: a b c
a,b,c=map(int,input().split()) if a+c==2*b: print(Yes) else: print(No)
Statement Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
[{"input": "2 4 6", "output": "YES\n \n\nSince 4-2 = 6-4, this arrangement of poles is beautiful.\n\n* * *"}, {"input": "2 5 6", "output": "NO\n \n\nSince 5-2 \\neq 6-5, this arrangement of poles is not beautiful.\n\n* * *"}, {"input": "3 2 1", "output": "YES\n \n\nSince 1-2 = 2-3, this arrangement of poles is beautiful."}]
Print `YES` if the arrangement of the poles is beautiful; print `NO` otherwise. * * *
s596320621
Runtime Error
p03759
Input is given from Standard Input in the following format: a b c
print("ABC" if int(input()) < 1000 else "ABD")
Statement Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
[{"input": "2 4 6", "output": "YES\n \n\nSince 4-2 = 6-4, this arrangement of poles is beautiful.\n\n* * *"}, {"input": "2 5 6", "output": "NO\n \n\nSince 5-2 \\neq 6-5, this arrangement of poles is not beautiful.\n\n* * *"}, {"input": "3 2 1", "output": "YES\n \n\nSince 1-2 = 2-3, this arrangement of poles is beautiful."}]
Print `YES` if the arrangement of the poles is beautiful; print `NO` otherwise. * * *
s398589610
Runtime Error
p03759
Input is given from Standard Input in the following format: a b c
a, b, c = map(int, input().split) print("YES") if b - a == c - b else print("YES")
Statement Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
[{"input": "2 4 6", "output": "YES\n \n\nSince 4-2 = 6-4, this arrangement of poles is beautiful.\n\n* * *"}, {"input": "2 5 6", "output": "NO\n \n\nSince 5-2 \\neq 6-5, this arrangement of poles is not beautiful.\n\n* * *"}, {"input": "3 2 1", "output": "YES\n \n\nSince 1-2 = 2-3, this arrangement of poles is beautiful."}]
Print `YES` if the arrangement of the poles is beautiful; print `NO` otherwise. * * *
s900374540
Runtime Error
p03759
Input is given from Standard Input in the following format: a b c
a, b, c = map(int, input().split()) print("YES" if b-a=c-b else "NO")
Statement Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
[{"input": "2 4 6", "output": "YES\n \n\nSince 4-2 = 6-4, this arrangement of poles is beautiful.\n\n* * *"}, {"input": "2 5 6", "output": "NO\n \n\nSince 5-2 \\neq 6-5, this arrangement of poles is not beautiful.\n\n* * *"}, {"input": "3 2 1", "output": "YES\n \n\nSince 1-2 = 2-3, this arrangement of poles is beautiful."}]
Print `YES` if the arrangement of the poles is beautiful; print `NO` otherwise. * * *
s390437493
Runtime Error
p03759
Input is given from Standard Input in the following format: a b c
if a-b=c-b: print("YES") else: print("NO")
Statement Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
[{"input": "2 4 6", "output": "YES\n \n\nSince 4-2 = 6-4, this arrangement of poles is beautiful.\n\n* * *"}, {"input": "2 5 6", "output": "NO\n \n\nSince 5-2 \\neq 6-5, this arrangement of poles is not beautiful.\n\n* * *"}, {"input": "3 2 1", "output": "YES\n \n\nSince 1-2 = 2-3, this arrangement of poles is beautiful."}]
Print `YES` if the arrangement of the poles is beautiful; print `NO` otherwise. * * *
s553985493
Runtime Error
p03759
Input is given from Standard Input in the following format: a b c
print("YES" if int(input()) - 2 * int(input()) + int(input()) == 0 else "NO")
Statement Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
[{"input": "2 4 6", "output": "YES\n \n\nSince 4-2 = 6-4, this arrangement of poles is beautiful.\n\n* * *"}, {"input": "2 5 6", "output": "NO\n \n\nSince 5-2 \\neq 6-5, this arrangement of poles is not beautiful.\n\n* * *"}, {"input": "3 2 1", "output": "YES\n \n\nSince 1-2 = 2-3, this arrangement of poles is beautiful."}]
Print `YES` if the arrangement of the poles is beautiful; print `NO` otherwise. * * *
s810274007
Runtime Error
p03759
Input is given from Standard Input in the following format: a b c
a, b, c =map(int, input().split()) print("Yes" if b-a=c-b else "No")
Statement Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
[{"input": "2 4 6", "output": "YES\n \n\nSince 4-2 = 6-4, this arrangement of poles is beautiful.\n\n* * *"}, {"input": "2 5 6", "output": "NO\n \n\nSince 5-2 \\neq 6-5, this arrangement of poles is not beautiful.\n\n* * *"}, {"input": "3 2 1", "output": "YES\n \n\nSince 1-2 = 2-3, this arrangement of poles is beautiful."}]
Print `YES` if the arrangement of the poles is beautiful; print `NO` otherwise. * * *
s385656067
Runtime Error
p03759
Input is given from Standard Input in the following format: a b c
a,b,c=map(int,input().split()) if b-c==c=b: print('YES') else: print('NO')
Statement Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
[{"input": "2 4 6", "output": "YES\n \n\nSince 4-2 = 6-4, this arrangement of poles is beautiful.\n\n* * *"}, {"input": "2 5 6", "output": "NO\n \n\nSince 5-2 \\neq 6-5, this arrangement of poles is not beautiful.\n\n* * *"}, {"input": "3 2 1", "output": "YES\n \n\nSince 1-2 = 2-3, this arrangement of poles is beautiful."}]
Print `YES` if the arrangement of the poles is beautiful; print `NO` otherwise. * * *
s338595115
Wrong Answer
p03759
Input is given from Standard Input in the following format: a b c
Statement Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
[{"input": "2 4 6", "output": "YES\n \n\nSince 4-2 = 6-4, this arrangement of poles is beautiful.\n\n* * *"}, {"input": "2 5 6", "output": "NO\n \n\nSince 5-2 \\neq 6-5, this arrangement of poles is not beautiful.\n\n* * *"}, {"input": "3 2 1", "output": "YES\n \n\nSince 1-2 = 2-3, this arrangement of poles is beautiful."}]
Print `YES` if the arrangement of the poles is beautiful; print `NO` otherwise. * * *
s029381525
Runtime Error
p03759
Input is given from Standard Input in the following format: a b c
a, b, c = map(int, input().split()) ans = 'NO' if b - a == c = b: ans = 'YES' print(ans)
Statement Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
[{"input": "2 4 6", "output": "YES\n \n\nSince 4-2 = 6-4, this arrangement of poles is beautiful.\n\n* * *"}, {"input": "2 5 6", "output": "NO\n \n\nSince 5-2 \\neq 6-5, this arrangement of poles is not beautiful.\n\n* * *"}, {"input": "3 2 1", "output": "YES\n \n\nSince 1-2 = 2-3, this arrangement of poles is beautiful."}]
Print `YES` if the arrangement of the poles is beautiful; print `NO` otherwise. * * *
s698788682
Runtime Error
p03759
Input is given from Standard Input in the following format: a b c
a, b, c -= map(int, input().split()) if b - a == c - b: print("YES") else: print("NO")
Statement Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
[{"input": "2 4 6", "output": "YES\n \n\nSince 4-2 = 6-4, this arrangement of poles is beautiful.\n\n* * *"}, {"input": "2 5 6", "output": "NO\n \n\nSince 5-2 \\neq 6-5, this arrangement of poles is not beautiful.\n\n* * *"}, {"input": "3 2 1", "output": "YES\n \n\nSince 1-2 = 2-3, this arrangement of poles is beautiful."}]
Print `YES` if the arrangement of the poles is beautiful; print `NO` otherwise. * * *
s300088614
Runtime Error
p03759
Input is given from Standard Input in the following format: a b c
a, b, c = list(map(int, input().split())) if b−a == c−b: print("YES") else: print("NO")
Statement Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
[{"input": "2 4 6", "output": "YES\n \n\nSince 4-2 = 6-4, this arrangement of poles is beautiful.\n\n* * *"}, {"input": "2 5 6", "output": "NO\n \n\nSince 5-2 \\neq 6-5, this arrangement of poles is not beautiful.\n\n* * *"}, {"input": "3 2 1", "output": "YES\n \n\nSince 1-2 = 2-3, this arrangement of poles is beautiful."}]
Print `YES` if the arrangement of the poles is beautiful; print `NO` otherwise. * * *
s877992740
Runtime Error
p03759
Input is given from Standard Input in the following format: a b c
a,b,c = map(int, input().split()) if b − a == c − b: print("YES"): else: print("NO")
Statement Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
[{"input": "2 4 6", "output": "YES\n \n\nSince 4-2 = 6-4, this arrangement of poles is beautiful.\n\n* * *"}, {"input": "2 5 6", "output": "NO\n \n\nSince 5-2 \\neq 6-5, this arrangement of poles is not beautiful.\n\n* * *"}, {"input": "3 2 1", "output": "YES\n \n\nSince 1-2 = 2-3, this arrangement of poles is beautiful."}]
Print `YES` if the arrangement of the poles is beautiful; print `NO` otherwise. * * *
s389055124
Runtime Error
p03759
Input is given from Standard Input in the following format: a b c
a, b, c = map(int, input().split()) if (b − a == c − b): print('YES') else: print('NO')
Statement Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
[{"input": "2 4 6", "output": "YES\n \n\nSince 4-2 = 6-4, this arrangement of poles is beautiful.\n\n* * *"}, {"input": "2 5 6", "output": "NO\n \n\nSince 5-2 \\neq 6-5, this arrangement of poles is not beautiful.\n\n* * *"}, {"input": "3 2 1", "output": "YES\n \n\nSince 1-2 = 2-3, this arrangement of poles is beautiful."}]
Print `YES` if the arrangement of the poles is beautiful; print `NO` otherwise. * * *
s659523790
Runtime Error
p03759
Input is given from Standard Input in the following format: a b c
a, b, c = map(int, input().split()) if b - a == c - b: print('YES') else: print('NO')
Statement Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
[{"input": "2 4 6", "output": "YES\n \n\nSince 4-2 = 6-4, this arrangement of poles is beautiful.\n\n* * *"}, {"input": "2 5 6", "output": "NO\n \n\nSince 5-2 \\neq 6-5, this arrangement of poles is not beautiful.\n\n* * *"}, {"input": "3 2 1", "output": "YES\n \n\nSince 1-2 = 2-3, this arrangement of poles is beautiful."}]