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 the largest possible number of different letters contained in both X and
Y.
* * * | s663347625 | Accepted | p03338 | Input is given from Standard Input in the following format:
N
S | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Feb 11 05:38:56 2019
@author: shinjisu
"""
# ABC 200็นๅ้ก
import math
def getInt():
return int(input())
def getIntList():
return [int(x) for x in input().split()]
def zeros(n):
return [0] * n
def dmp(x):
global debug
if debug:
print(x)
debug = True
def getIntLines(n):
return [int(input()) for i in range(n)]
def getIntMat(n):
mat = []
for i in range(n):
mat.append(getIntList())
return mat
def zeros2(n, m):
return [zeros(m)] * n
def prob096(): # Maximum Sum
X = getIntList()
K = getInt()
dmp((X, K))
total = sum(X) - max(X) + max(X) * 2**K
return total
def prob097(): # Exponential
X = getInt()
dmp(X)
if X == 1:
return 1
for n in range(X, 0, -1):
dmp(n)
for b in range(2, int(math.sqrt(X)) + 1):
a = n
exp = True
while a > 1:
if a % b != 0:
exp = False
break
a //= b
if exp:
break
if exp:
break
return n
def prob098(): # Cut and Count
N = getInt()
S = input()
dmp((N, S))
maxChCount = 0
for i in range(1, N):
before = S[:i]
after = S[i:]
dmp((before, after))
chCount = 0
for j in range(26):
ch = chr(ord("a") + j)
if ch in before and ch in after:
chCount += 1
maxChCount = max(maxChCount, chCount)
return maxChCount
debug = False # True False
print(prob098())
| Statement
You are given a string S of length N consisting of lowercase English letters.
We will cut this string at one position into two strings X and Y. Here, we
would like to maximize the number of different letters contained in both X and
Y. Find the largest possible number of different letters contained in both X
and Y when we cut the string at the optimal position. | [{"input": "6\n aabbca", "output": "2\n \n\nIf we cut the string between the third and fourth letters into X = `aab` and Y\n= `bca`, the letters contained in both X and Y are `a` and `b`. There will\nnever be three or more different letters contained in both X and Y, so the\nanswer is 2.\n\n* * *"}, {"input": "10\n aaaaaaaaaa", "output": "1\n \n\nHowever we divide S, only `a` will be contained in both X and Y.\n\n* * *"}, {"input": "45\n tgxgdqkyjzhyputjjtllptdfxocrylqfqjynmfbfucbir", "output": "9"}] |
Print the largest possible number of different letters contained in both X and
Y.
* * * | s749760880 | Accepted | p03338 | Input is given from Standard Input in the following format:
N
S | from collections import Counter
def solve(n, s):
c = Counter(s)
ret, tmp = 0, 0
d = set()
for l in s:
c[l] -= 1
if c[l] == 0:
tmp -= 1
if l not in d:
tmp += 1
d.add(l)
if ret < tmp:
ret = tmp
return ret
_n = int(input())
_s = input()
print(solve(_n, _s))
| Statement
You are given a string S of length N consisting of lowercase English letters.
We will cut this string at one position into two strings X and Y. Here, we
would like to maximize the number of different letters contained in both X and
Y. Find the largest possible number of different letters contained in both X
and Y when we cut the string at the optimal position. | [{"input": "6\n aabbca", "output": "2\n \n\nIf we cut the string between the third and fourth letters into X = `aab` and Y\n= `bca`, the letters contained in both X and Y are `a` and `b`. There will\nnever be three or more different letters contained in both X and Y, so the\nanswer is 2.\n\n* * *"}, {"input": "10\n aaaaaaaaaa", "output": "1\n \n\nHowever we divide S, only `a` will be contained in both X and Y.\n\n* * *"}, {"input": "45\n tgxgdqkyjzhyputjjtllptdfxocrylqfqjynmfbfucbir", "output": "9"}] |
Print the largest possible number of different letters contained in both X and
Y.
* * * | s593507596 | Wrong Answer | p03338 | Input is given from Standard Input in the following format:
N
S | N = int(input())
S = str(input())
letters = "abcdefghijklmnopqrstuvwxyz"
max_num = 0
for i in range(1, len(letters)):
S1 = S[0:i]
S2 = S[i:N]
count = 0
for k in range(26):
n1 = len([1 for x in S1 if x == letters[k]])
n2 = len([1 for x in S2 if x == letters[k]])
if n1 > 0 and n2 > 0:
count = count + 1
if max_num < count:
max_num = count
print(max_num)
| Statement
You are given a string S of length N consisting of lowercase English letters.
We will cut this string at one position into two strings X and Y. Here, we
would like to maximize the number of different letters contained in both X and
Y. Find the largest possible number of different letters contained in both X
and Y when we cut the string at the optimal position. | [{"input": "6\n aabbca", "output": "2\n \n\nIf we cut the string between the third and fourth letters into X = `aab` and Y\n= `bca`, the letters contained in both X and Y are `a` and `b`. There will\nnever be three or more different letters contained in both X and Y, so the\nanswer is 2.\n\n* * *"}, {"input": "10\n aaaaaaaaaa", "output": "1\n \n\nHowever we divide S, only `a` will be contained in both X and Y.\n\n* * *"}, {"input": "45\n tgxgdqkyjzhyputjjtllptdfxocrylqfqjynmfbfucbir", "output": "9"}] |
Print the largest possible number of different letters contained in both X and
Y.
* * * | s336836768 | Runtime Error | p03338 | Input is given from Standard Input in the following format:
N
S | import numpy as np
N=int(input())
S=str(input())
s_list = "abcdefghijklmnopqrstuvwxyz"
count_list = np.zeros(26)
max_count = 0
for i in range(N-1): # Nๅญ็ฎใงๅใฃใๅ ดๅ
for k in range(i):
if S[k] in S[N:len(S)]:
count_list[s_list.index(S[k])] = count_list[s_list.index(S[k])] + 1
if max_count < n = len([1 for x in count_list if x>0])
print(max_count) | Statement
You are given a string S of length N consisting of lowercase English letters.
We will cut this string at one position into two strings X and Y. Here, we
would like to maximize the number of different letters contained in both X and
Y. Find the largest possible number of different letters contained in both X
and Y when we cut the string at the optimal position. | [{"input": "6\n aabbca", "output": "2\n \n\nIf we cut the string between the third and fourth letters into X = `aab` and Y\n= `bca`, the letters contained in both X and Y are `a` and `b`. There will\nnever be three or more different letters contained in both X and Y, so the\nanswer is 2.\n\n* * *"}, {"input": "10\n aaaaaaaaaa", "output": "1\n \n\nHowever we divide S, only `a` will be contained in both X and Y.\n\n* * *"}, {"input": "45\n tgxgdqkyjzhyputjjtllptdfxocrylqfqjynmfbfucbir", "output": "9"}] |
Print the largest possible number of different letters contained in both X and
Y.
* * * | s611556060 | Runtime Error | p03338 | Input is given from Standard Input in the following format:
N
S | N = int(input())
S = input()
posDevide = 1
maxMatchWordNum = 0
while posDevide < N:
arrayNum = 1
matchWordNum = 0
while arrayNum <= posDevide:
if arrayNum == S.find( S[ arrayNum - 1 ]:
matchWordNum = matchWordNum + 1 if bool( S.count( S[ arrayNum - 1 ], posDevide, N-1 )) else matchWordNum
arrayNum += 1
maxMatchWordNum = matchWordNum if matchWordNum > maxMatchWordNum else maxMatchWordNum
posDevide += 1
print(maxMatchWordNum) | Statement
You are given a string S of length N consisting of lowercase English letters.
We will cut this string at one position into two strings X and Y. Here, we
would like to maximize the number of different letters contained in both X and
Y. Find the largest possible number of different letters contained in both X
and Y when we cut the string at the optimal position. | [{"input": "6\n aabbca", "output": "2\n \n\nIf we cut the string between the third and fourth letters into X = `aab` and Y\n= `bca`, the letters contained in both X and Y are `a` and `b`. There will\nnever be three or more different letters contained in both X and Y, so the\nanswer is 2.\n\n* * *"}, {"input": "10\n aaaaaaaaaa", "output": "1\n \n\nHowever we divide S, only `a` will be contained in both X and Y.\n\n* * *"}, {"input": "45\n tgxgdqkyjzhyputjjtllptdfxocrylqfqjynmfbfucbir", "output": "9"}] |
Print the largest possible number of different letters contained in both X and
Y.
* * * | s358593235 | Runtime Error | p03338 | Input is given from Standard Input in the following format:
N
S | n = int(input())
s = input()
l_dict = {}
r_dict = {}
for c in s:
r_dict[c] = 0
l_dict[c] = 0
for c in s:
r_dict[c] += 1
ans = 0
for c in s:
l_dict[c] += 1
r_dict[c] -= 1
count = 0
for k, v in l_dict.items():
if v > 0:
if r_dict[k] > 0
count += 1
ans = max(ans, count)
print(ans)
| Statement
You are given a string S of length N consisting of lowercase English letters.
We will cut this string at one position into two strings X and Y. Here, we
would like to maximize the number of different letters contained in both X and
Y. Find the largest possible number of different letters contained in both X
and Y when we cut the string at the optimal position. | [{"input": "6\n aabbca", "output": "2\n \n\nIf we cut the string between the third and fourth letters into X = `aab` and Y\n= `bca`, the letters contained in both X and Y are `a` and `b`. There will\nnever be three or more different letters contained in both X and Y, so the\nanswer is 2.\n\n* * *"}, {"input": "10\n aaaaaaaaaa", "output": "1\n \n\nHowever we divide S, only `a` will be contained in both X and Y.\n\n* * *"}, {"input": "45\n tgxgdqkyjzhyputjjtllptdfxocrylqfqjynmfbfucbir", "output": "9"}] |
Print the largest possible number of different letters contained in both X and
Y.
* * * | s622138828 | Runtime Error | p03338 | Input is given from Standard Input in the following format:
N
S | ***
ใๆๅญๅใS ใใๆๅญๅใX ใจ ใๆๅญๅใY ใซๅๅฒใX ใจ Y ไธกๆนใซๅซใๆๅญ็จฎ้กๆฐๆๅคงๅ
ใๆๅญๅใS ใ ๅไฝ็ฝฎ ใง ๅๅฒใใฆใใ้ๅใX ใจ ใ้ๅใY ใซๆ ผ็ดใใใ
ใ้ๅใX ใจ ใ้ๅใY ใฎ ่ซ็็ฉ(AND) ใฎ ่ฆ็ด ๆฐ ใ ๆๅคงๅใใใใจใงๆฑใใใใจใใงใใใ
ใ้ๅใX ใจ ใ้ๅใY ใฎ ่ซ็็ฉ(AND) ใฏ X & Y ใงๆฑใใใใจใใงใใใ
***
N = int(input())
S = input()
answer = 0
for L in range(N):
left = S[:L]
right = S[L:]
both = set(left) & set(right)
answer = max(answer, len(both))
print(answer) | Statement
You are given a string S of length N consisting of lowercase English letters.
We will cut this string at one position into two strings X and Y. Here, we
would like to maximize the number of different letters contained in both X and
Y. Find the largest possible number of different letters contained in both X
and Y when we cut the string at the optimal position. | [{"input": "6\n aabbca", "output": "2\n \n\nIf we cut the string between the third and fourth letters into X = `aab` and Y\n= `bca`, the letters contained in both X and Y are `a` and `b`. There will\nnever be three or more different letters contained in both X and Y, so the\nanswer is 2.\n\n* * *"}, {"input": "10\n aaaaaaaaaa", "output": "1\n \n\nHowever we divide S, only `a` will be contained in both X and Y.\n\n* * *"}, {"input": "45\n tgxgdqkyjzhyputjjtllptdfxocrylqfqjynmfbfucbir", "output": "9"}] |
Print the largest possible number of different letters contained in both X and
Y.
* * * | s503480971 | Runtime Error | p03338 | Input is given from Standard Input in the following format:
N
S | n=int(input())
s=input()
maxx=-
def got(a,al):
for i in a:
if i==al:
return(True)
return(False)
for i in range(n):
a=s[:i]
b=s[i:]
cnt=0
alp="abcdefghijklmnopqrstuvwxyz"
for al in alp:
if got(a,al) and got(b,al):
cnt+=1
maxx=max(maxx,cnt)
print(maxx) | Statement
You are given a string S of length N consisting of lowercase English letters.
We will cut this string at one position into two strings X and Y. Here, we
would like to maximize the number of different letters contained in both X and
Y. Find the largest possible number of different letters contained in both X
and Y when we cut the string at the optimal position. | [{"input": "6\n aabbca", "output": "2\n \n\nIf we cut the string between the third and fourth letters into X = `aab` and Y\n= `bca`, the letters contained in both X and Y are `a` and `b`. There will\nnever be three or more different letters contained in both X and Y, so the\nanswer is 2.\n\n* * *"}, {"input": "10\n aaaaaaaaaa", "output": "1\n \n\nHowever we divide S, only `a` will be contained in both X and Y.\n\n* * *"}, {"input": "45\n tgxgdqkyjzhyputjjtllptdfxocrylqfqjynmfbfucbir", "output": "9"}] |
Print the largest possible number of different letters contained in both X and
Y.
* * * | s416317845 | Runtime Error | p03338 | Input is given from Standard Input in the following format:
N
S | N = int(input())
S = list(map(int,input().split()))
result_list = []
for i in range(N):
X = S[:i]
Y = S[i:]
counter = 0
old_list = []
for j in X:
if j in Y and not(j in old_list):
counter += 1 old_list.append(j)
result_list.append(counter)
print(max(result_list)) | Statement
You are given a string S of length N consisting of lowercase English letters.
We will cut this string at one position into two strings X and Y. Here, we
would like to maximize the number of different letters contained in both X and
Y. Find the largest possible number of different letters contained in both X
and Y when we cut the string at the optimal position. | [{"input": "6\n aabbca", "output": "2\n \n\nIf we cut the string between the third and fourth letters into X = `aab` and Y\n= `bca`, the letters contained in both X and Y are `a` and `b`. There will\nnever be three or more different letters contained in both X and Y, so the\nanswer is 2.\n\n* * *"}, {"input": "10\n aaaaaaaaaa", "output": "1\n \n\nHowever we divide S, only `a` will be contained in both X and Y.\n\n* * *"}, {"input": "45\n tgxgdqkyjzhyputjjtllptdfxocrylqfqjynmfbfucbir", "output": "9"}] |
Print the largest possible number of different letters contained in both X and
Y.
* * * | s386007507 | Runtime Error | p03338 | Input is given from Standard Input in the following format:
N
S |
Copy
Copy
N = int(input())
S = input()
max_cnt = 0
for i in range(N):
li1 = [0]*26
li2 = [0]*26
cnt = 0
for j in S[i:]:
li[ord(j)-97]+=1
for j in S[:i]:
li[ord(j)-97]+=1
for j in range(26):
if(li1[j]>0 and li2[j]>0):
cnt += 1
max_cnt = max(max_cnt,cnt)
print(max_cnt) | Statement
You are given a string S of length N consisting of lowercase English letters.
We will cut this string at one position into two strings X and Y. Here, we
would like to maximize the number of different letters contained in both X and
Y. Find the largest possible number of different letters contained in both X
and Y when we cut the string at the optimal position. | [{"input": "6\n aabbca", "output": "2\n \n\nIf we cut the string between the third and fourth letters into X = `aab` and Y\n= `bca`, the letters contained in both X and Y are `a` and `b`. There will\nnever be three or more different letters contained in both X and Y, so the\nanswer is 2.\n\n* * *"}, {"input": "10\n aaaaaaaaaa", "output": "1\n \n\nHowever we divide S, only `a` will be contained in both X and Y.\n\n* * *"}, {"input": "45\n tgxgdqkyjzhyputjjtllptdfxocrylqfqjynmfbfucbir", "output": "9"}] |
Print the largest possible number of different letters contained in both X and
Y.
* * * | s968047054 | Runtime Error | p03338 | Input is given from Standard Input in the following format:
N
S | # ๅ
ฅๅใฎๅใๅใ
n = int(input())
list = list(input().split())
# ๅ
จ็จฎ้ก็จๆใใจใ
alphabets_list = lsit("abcdefghijklmnopqrstuvwxyz".split())
# ๅคๅฎ
for i in range(1, n - 1):
x = list[ :i]
y = list[i: ]
count = 0
for alphabet in alphabets_list:
if alphabet in x and alphabet in y:
count += 1
else:
continue
print(continue)
| Statement
You are given a string S of length N consisting of lowercase English letters.
We will cut this string at one position into two strings X and Y. Here, we
would like to maximize the number of different letters contained in both X and
Y. Find the largest possible number of different letters contained in both X
and Y when we cut the string at the optimal position. | [{"input": "6\n aabbca", "output": "2\n \n\nIf we cut the string between the third and fourth letters into X = `aab` and Y\n= `bca`, the letters contained in both X and Y are `a` and `b`. There will\nnever be three or more different letters contained in both X and Y, so the\nanswer is 2.\n\n* * *"}, {"input": "10\n aaaaaaaaaa", "output": "1\n \n\nHowever we divide S, only `a` will be contained in both X and Y.\n\n* * *"}, {"input": "45\n tgxgdqkyjzhyputjjtllptdfxocrylqfqjynmfbfucbir", "output": "9"}] |
Print the largest possible number of different letters contained in both X and
Y.
* * * | s063065920 | Runtime Error | p03338 | Input is given from Standard Input in the following format:
N
S | N = int(input())
S = list(input())
print(max([len(set(S[:i]) & set(S[i:])) for | Statement
You are given a string S of length N consisting of lowercase English letters.
We will cut this string at one position into two strings X and Y. Here, we
would like to maximize the number of different letters contained in both X and
Y. Find the largest possible number of different letters contained in both X
and Y when we cut the string at the optimal position. | [{"input": "6\n aabbca", "output": "2\n \n\nIf we cut the string between the third and fourth letters into X = `aab` and Y\n= `bca`, the letters contained in both X and Y are `a` and `b`. There will\nnever be three or more different letters contained in both X and Y, so the\nanswer is 2.\n\n* * *"}, {"input": "10\n aaaaaaaaaa", "output": "1\n \n\nHowever we divide S, only `a` will be contained in both X and Y.\n\n* * *"}, {"input": "45\n tgxgdqkyjzhyputjjtllptdfxocrylqfqjynmfbfucbir", "output": "9"}] |
Print the largest possible number of different letters contained in both X and
Y.
* * * | s058062327 | Runtime Error | p03338 | Input is given from Standard Input in the following format:
N
S | n=int(input());s=input();print(max(len(set(s[:i])&set(s[i:]))for i in range(n)) | Statement
You are given a string S of length N consisting of lowercase English letters.
We will cut this string at one position into two strings X and Y. Here, we
would like to maximize the number of different letters contained in both X and
Y. Find the largest possible number of different letters contained in both X
and Y when we cut the string at the optimal position. | [{"input": "6\n aabbca", "output": "2\n \n\nIf we cut the string between the third and fourth letters into X = `aab` and Y\n= `bca`, the letters contained in both X and Y are `a` and `b`. There will\nnever be three or more different letters contained in both X and Y, so the\nanswer is 2.\n\n* * *"}, {"input": "10\n aaaaaaaaaa", "output": "1\n \n\nHowever we divide S, only `a` will be contained in both X and Y.\n\n* * *"}, {"input": "45\n tgxgdqkyjzhyputjjtllptdfxocrylqfqjynmfbfucbir", "output": "9"}] |
Print the largest possible number of different letters contained in both X and
Y.
* * * | s612893439 | Runtime Error | p03338 | Input is given from Standard Input in the following format:
N
S | n=int(input())
s-list(input())
ans=0
for i in range(1,n-1):
ans=max(ans,len(set(s[:i]|set(s[i:])))
print(ans) | Statement
You are given a string S of length N consisting of lowercase English letters.
We will cut this string at one position into two strings X and Y. Here, we
would like to maximize the number of different letters contained in both X and
Y. Find the largest possible number of different letters contained in both X
and Y when we cut the string at the optimal position. | [{"input": "6\n aabbca", "output": "2\n \n\nIf we cut the string between the third and fourth letters into X = `aab` and Y\n= `bca`, the letters contained in both X and Y are `a` and `b`. There will\nnever be three or more different letters contained in both X and Y, so the\nanswer is 2.\n\n* * *"}, {"input": "10\n aaaaaaaaaa", "output": "1\n \n\nHowever we divide S, only `a` will be contained in both X and Y.\n\n* * *"}, {"input": "45\n tgxgdqkyjzhyputjjtllptdfxocrylqfqjynmfbfucbir", "output": "9"}] |
Print the largest possible number of different letters contained in both X and
Y.
* * * | s466193636 | Accepted | p03338 | Input is given from Standard Input in the following format:
N
S | icase = 0
if icase == 0:
n = int(input())
s = list(input())
icmax = 0
for i in range(n):
si = set(s[0:i])
ti = set(s[i:n])
icnt = len(si & ti)
icmax = max(icmax, icnt)
print(icmax)
| Statement
You are given a string S of length N consisting of lowercase English letters.
We will cut this string at one position into two strings X and Y. Here, we
would like to maximize the number of different letters contained in both X and
Y. Find the largest possible number of different letters contained in both X
and Y when we cut the string at the optimal position. | [{"input": "6\n aabbca", "output": "2\n \n\nIf we cut the string between the third and fourth letters into X = `aab` and Y\n= `bca`, the letters contained in both X and Y are `a` and `b`. There will\nnever be three or more different letters contained in both X and Y, so the\nanswer is 2.\n\n* * *"}, {"input": "10\n aaaaaaaaaa", "output": "1\n \n\nHowever we divide S, only `a` will be contained in both X and Y.\n\n* * *"}, {"input": "45\n tgxgdqkyjzhyputjjtllptdfxocrylqfqjynmfbfucbir", "output": "9"}] |
Print the largest possible number of different letters contained in both X and
Y.
* * * | s745443835 | Runtime Error | p03338 | Input is given from Standard Input in the following format:
N
S | N = int(input())
S = input()
ans = 0
for i in range(1, N):
left = [:i]
right = [i:]
cnt = 0
both = []
for j in range(len(right)):
if right[j] in left and not right[j] in both:
cnt += 1
both.append(right[j])
ans = max(ans, cnt)
print(ans) | Statement
You are given a string S of length N consisting of lowercase English letters.
We will cut this string at one position into two strings X and Y. Here, we
would like to maximize the number of different letters contained in both X and
Y. Find the largest possible number of different letters contained in both X
and Y when we cut the string at the optimal position. | [{"input": "6\n aabbca", "output": "2\n \n\nIf we cut the string between the third and fourth letters into X = `aab` and Y\n= `bca`, the letters contained in both X and Y are `a` and `b`. There will\nnever be three or more different letters contained in both X and Y, so the\nanswer is 2.\n\n* * *"}, {"input": "10\n aaaaaaaaaa", "output": "1\n \n\nHowever we divide S, only `a` will be contained in both X and Y.\n\n* * *"}, {"input": "45\n tgxgdqkyjzhyputjjtllptdfxocrylqfqjynmfbfucbir", "output": "9"}] |
Print the largest possible number of different letters contained in both X and
Y.
* * * | s133023258 | Runtime Error | p03338 | Input is given from Standard Input in the following format:
N
S | N=Int(input())
S=input()
for i in range(N):
SR=S[(i+1):]
SL=S[:(i+1)]
count=0
for j in SL:
for k in SR:
if(SL[j]===SR[k]):
count++
break
if(count_M<count):
count_M=count
print(count)
| Statement
You are given a string S of length N consisting of lowercase English letters.
We will cut this string at one position into two strings X and Y. Here, we
would like to maximize the number of different letters contained in both X and
Y. Find the largest possible number of different letters contained in both X
and Y when we cut the string at the optimal position. | [{"input": "6\n aabbca", "output": "2\n \n\nIf we cut the string between the third and fourth letters into X = `aab` and Y\n= `bca`, the letters contained in both X and Y are `a` and `b`. There will\nnever be three or more different letters contained in both X and Y, so the\nanswer is 2.\n\n* * *"}, {"input": "10\n aaaaaaaaaa", "output": "1\n \n\nHowever we divide S, only `a` will be contained in both X and Y.\n\n* * *"}, {"input": "45\n tgxgdqkyjzhyputjjtllptdfxocrylqfqjynmfbfucbir", "output": "9"}] |
Print the largest possible number of different letters contained in both X and
Y.
* * * | s961207080 | Runtime Error | p03338 | Input is given from Standard Input in the following format:
N
S | n = int(input())
s = list(input())
former = set(s[0])
latter = set(s[1:])
ans = len(former & latter)
for i in range(2, n):
former = set(s[:i])
latter = set(s[i:])
if len(former & latter) > ans:
ans = len(former & latter)
print(ans) | Statement
You are given a string S of length N consisting of lowercase English letters.
We will cut this string at one position into two strings X and Y. Here, we
would like to maximize the number of different letters contained in both X and
Y. Find the largest possible number of different letters contained in both X
and Y when we cut the string at the optimal position. | [{"input": "6\n aabbca", "output": "2\n \n\nIf we cut the string between the third and fourth letters into X = `aab` and Y\n= `bca`, the letters contained in both X and Y are `a` and `b`. There will\nnever be three or more different letters contained in both X and Y, so the\nanswer is 2.\n\n* * *"}, {"input": "10\n aaaaaaaaaa", "output": "1\n \n\nHowever we divide S, only `a` will be contained in both X and Y.\n\n* * *"}, {"input": "45\n tgxgdqkyjzhyputjjtllptdfxocrylqfqjynmfbfucbir", "output": "9"}] |
Print the largest possible number of different letters contained in both X and
Y.
* * * | s411453979 | Runtime Error | p03338 | Input is given from Standard Input in the following format:
N
S | \def main():
n = int(input())
s = input()
ma = 0
for i in range(1, n):
x = s[:i]
y = s[i:]
ma = max(ma, count_same(x, y))
print(ma)
def count_same(x, y):
return len(set(x) & set(y))
if __name__ == '__main__':
main()
| Statement
You are given a string S of length N consisting of lowercase English letters.
We will cut this string at one position into two strings X and Y. Here, we
would like to maximize the number of different letters contained in both X and
Y. Find the largest possible number of different letters contained in both X
and Y when we cut the string at the optimal position. | [{"input": "6\n aabbca", "output": "2\n \n\nIf we cut the string between the third and fourth letters into X = `aab` and Y\n= `bca`, the letters contained in both X and Y are `a` and `b`. There will\nnever be three or more different letters contained in both X and Y, so the\nanswer is 2.\n\n* * *"}, {"input": "10\n aaaaaaaaaa", "output": "1\n \n\nHowever we divide S, only `a` will be contained in both X and Y.\n\n* * *"}, {"input": "45\n tgxgdqkyjzhyputjjtllptdfxocrylqfqjynmfbfucbir", "output": "9"}] |
Print the largest possible number of different letters contained in both X and
Y.
* * * | s376800359 | Accepted | p03338 | Input is given from Standard Input in the following format:
N
S | N = int(input())
text = input()
result = []
for i in range(N - 1):
counter = 0
text1 = text[0 : i + 1]
text2 = text[i + 1 :]
if "a" in text1:
if "a" in text2:
counter = counter + 1
if "b" in text1:
if "b" in text2:
counter = counter + 1
if "c" in text1:
if "c" in text2:
counter = counter + 1
if "d" in text1:
if "d" in text2:
counter = counter + 1
if "e" in text1:
if "e" in text2:
counter = counter + 1
if "f" in text1:
if "f" in text2:
counter = counter + 1
if "g" in text1:
if "g" in text2:
counter = counter + 1
if "h" in text1:
if "h" in text2:
counter = counter + 1
if "i" in text1:
if "i" in text2:
counter = counter + 1
if "j" in text1:
if "j" in text2:
counter = counter + 1
if "k" in text1:
if "k" in text2:
counter = counter + 1
if "l" in text1:
if "l" in text2:
counter = counter + 1
if "m" in text1:
if "m" in text2:
counter = counter + 1
if "n" in text1:
if "n" in text2:
counter = counter + 1
if "o" in text1:
if "o" in text2:
counter = counter + 1
if "p" in text1:
if "p" in text2:
counter = counter + 1
if "q" in text1:
if "q" in text2:
counter = counter + 1
if "r" in text1:
if "r" in text2:
counter = counter + 1
if "s" in text1:
if "s" in text2:
counter = counter + 1
if "t" in text1:
if "t" in text2:
counter = counter + 1
if "u" in text1:
if "u" in text2:
counter = counter + 1
if "v" in text1:
if "v" in text2:
counter = counter + 1
if "w" in text1:
if "w" in text2:
counter = counter + 1
if "x" in text1:
if "x" in text2:
counter = counter + 1
if "y" in text1:
if "y" in text2:
counter = counter + 1
if "z" in text1:
if "z" in text2:
counter = counter + 1
result = result + [counter]
print(max(result))
| Statement
You are given a string S of length N consisting of lowercase English letters.
We will cut this string at one position into two strings X and Y. Here, we
would like to maximize the number of different letters contained in both X and
Y. Find the largest possible number of different letters contained in both X
and Y when we cut the string at the optimal position. | [{"input": "6\n aabbca", "output": "2\n \n\nIf we cut the string between the third and fourth letters into X = `aab` and Y\n= `bca`, the letters contained in both X and Y are `a` and `b`. There will\nnever be three or more different letters contained in both X and Y, so the\nanswer is 2.\n\n* * *"}, {"input": "10\n aaaaaaaaaa", "output": "1\n \n\nHowever we divide S, only `a` will be contained in both X and Y.\n\n* * *"}, {"input": "45\n tgxgdqkyjzhyputjjtllptdfxocrylqfqjynmfbfucbir", "output": "9"}] |
Print the largest possible number of different letters contained in both X and
Y.
* * * | s398113175 | Runtime Error | p03338 | Input is given from Standard Input in the following format:
N
S | N = int(input())
text = input()
result = []
for i in range(N - 2):
counter = 0
text1 = text[0 : i + 2]
text2 = text[i + 2 :]
if "a" in text1 and text2:
counter = counter + 1
if "b" in text1 and text2:
counter = counter + 1
if "c" in text1 and text2:
counter = counter + 1
if "d" in text1 and text2:
counter = counter + 1
if "e" in text1 and text2:
counter = counter + 1
if "f" in text1 and text2:
counter = counter + 1
if "g" in text1 and text2:
counter = counter + 1
if "h" in text1 and text2:
counter = counter + 1
if "i" in text1 and text2:
counter = counter + 1
if "j" in text1 and text2:
counter = counter + 1
if "k" in text1 and text2:
counter = counter + 1
if "l" in text1 and text2:
counter = counter + 1
if "m" in text1 and text2:
counter = counter + 1
if "n" in text1 and text2:
counter = counter + 1
if "o" in text1 and text2:
counter = counter + 1
if "p" in text1 and text2:
counter = counter + 1
if "q" in text1 and text2:
counter = counter + 1
if "r" in text1 and text2:
counter = counter + 1
if "s" in text1 and text2:
counter = counter + 1
if "t" in text1 and text2:
counter = counter + 1
if "u" in text1 and text2:
counter = counter + 1
if "v" in text1 and text2:
counter = counter + 1
if "w" in text1 and text2:
counter = counter + 1
if "x" in text1 and text2:
counter = counter + 1
if "y" in text1 and text2:
counter = counter + 1
if "z" in text1 and text2:
counter = counter + 1
result = result + [counter]
print(max(result))
| Statement
You are given a string S of length N consisting of lowercase English letters.
We will cut this string at one position into two strings X and Y. Here, we
would like to maximize the number of different letters contained in both X and
Y. Find the largest possible number of different letters contained in both X
and Y when we cut the string at the optimal position. | [{"input": "6\n aabbca", "output": "2\n \n\nIf we cut the string between the third and fourth letters into X = `aab` and Y\n= `bca`, the letters contained in both X and Y are `a` and `b`. There will\nnever be three or more different letters contained in both X and Y, so the\nanswer is 2.\n\n* * *"}, {"input": "10\n aaaaaaaaaa", "output": "1\n \n\nHowever we divide S, only `a` will be contained in both X and Y.\n\n* * *"}, {"input": "45\n tgxgdqkyjzhyputjjtllptdfxocrylqfqjynmfbfucbir", "output": "9"}] |
Print the largest possible number of different letters contained in both X and
Y.
* * * | s260344875 | Runtime Error | p03338 | Input is given from Standard Input in the following format:
N
S | num = int(input())
li = list(input())
ans = 0
for i in range(num):
fi = set(li[:i])
se = set(li[i:])
hoge = len(list(fi & se))
if hoge > ans:
ans = hoge
print(ans) | Statement
You are given a string S of length N consisting of lowercase English letters.
We will cut this string at one position into two strings X and Y. Here, we
would like to maximize the number of different letters contained in both X and
Y. Find the largest possible number of different letters contained in both X
and Y when we cut the string at the optimal position. | [{"input": "6\n aabbca", "output": "2\n \n\nIf we cut the string between the third and fourth letters into X = `aab` and Y\n= `bca`, the letters contained in both X and Y are `a` and `b`. There will\nnever be three or more different letters contained in both X and Y, so the\nanswer is 2.\n\n* * *"}, {"input": "10\n aaaaaaaaaa", "output": "1\n \n\nHowever we divide S, only `a` will be contained in both X and Y.\n\n* * *"}, {"input": "45\n tgxgdqkyjzhyputjjtllptdfxocrylqfqjynmfbfucbir", "output": "9"}] |
Print the largest possible number of different letters contained in both X and
Y.
* * * | s473008305 | Runtime Error | p03338 | Input is given from Standard Input in the following format:
N
S | N = int(input())
S = input()
print(max([len(set(S[:i]).intersection(set(S[i:]))) for i in range(N)])) | Statement
You are given a string S of length N consisting of lowercase English letters.
We will cut this string at one position into two strings X and Y. Here, we
would like to maximize the number of different letters contained in both X and
Y. Find the largest possible number of different letters contained in both X
and Y when we cut the string at the optimal position. | [{"input": "6\n aabbca", "output": "2\n \n\nIf we cut the string between the third and fourth letters into X = `aab` and Y\n= `bca`, the letters contained in both X and Y are `a` and `b`. There will\nnever be three or more different letters contained in both X and Y, so the\nanswer is 2.\n\n* * *"}, {"input": "10\n aaaaaaaaaa", "output": "1\n \n\nHowever we divide S, only `a` will be contained in both X and Y.\n\n* * *"}, {"input": "45\n tgxgdqkyjzhyputjjtllptdfxocrylqfqjynmfbfucbir", "output": "9"}] |
Print the largest possible number of different letters contained in both X and
Y.
* * * | s966644641 | Runtime Error | p03338 | Input is given from Standard Input in the following format:
N
S | N = int(input())
S = input()
ans = 0
for i in range(N):
ans = max(ans,len(set(s[:i]) & set(s[i:]))
print(ans) | Statement
You are given a string S of length N consisting of lowercase English letters.
We will cut this string at one position into two strings X and Y. Here, we
would like to maximize the number of different letters contained in both X and
Y. Find the largest possible number of different letters contained in both X
and Y when we cut the string at the optimal position. | [{"input": "6\n aabbca", "output": "2\n \n\nIf we cut the string between the third and fourth letters into X = `aab` and Y\n= `bca`, the letters contained in both X and Y are `a` and `b`. There will\nnever be three or more different letters contained in both X and Y, so the\nanswer is 2.\n\n* * *"}, {"input": "10\n aaaaaaaaaa", "output": "1\n \n\nHowever we divide S, only `a` will be contained in both X and Y.\n\n* * *"}, {"input": "45\n tgxgdqkyjzhyputjjtllptdfxocrylqfqjynmfbfucbir", "output": "9"}] |
Print the largest possible number of different letters contained in both X and
Y.
* * * | s003266564 | Runtime Error | p03338 | Input is given from Standard Input in the following format:
N
S | n = int(input())
s = list(input())
if n%2 == 0:
s1 = set(s[:n//2])
s2 = set(s[n//2:])
print(len(s1&s2))
else:
s1 = set(s[:n//2])
s2 = set(s[n//2:])
s3 = set(s[:(n//2)+1])
s4 = set(s[(n//2)+1:])
print(max(len(s1&s2),len(s3,s4))) | Statement
You are given a string S of length N consisting of lowercase English letters.
We will cut this string at one position into two strings X and Y. Here, we
would like to maximize the number of different letters contained in both X and
Y. Find the largest possible number of different letters contained in both X
and Y when we cut the string at the optimal position. | [{"input": "6\n aabbca", "output": "2\n \n\nIf we cut the string between the third and fourth letters into X = `aab` and Y\n= `bca`, the letters contained in both X and Y are `a` and `b`. There will\nnever be three or more different letters contained in both X and Y, so the\nanswer is 2.\n\n* * *"}, {"input": "10\n aaaaaaaaaa", "output": "1\n \n\nHowever we divide S, only `a` will be contained in both X and Y.\n\n* * *"}, {"input": "45\n tgxgdqkyjzhyputjjtllptdfxocrylqfqjynmfbfucbir", "output": "9"}] |
Print the minimum total cost required to complete all the task.
* * * | s739379111 | Accepted | p03292 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | a, _, b = sorted(map(int, input().split()))
print(b - a)
| Statement
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 0.
Then, just after completing the i-th task, you can complete the j-th task at
cost |A_j - A_i|.
Here, |x| denotes the absolute value of x.
Find the minimum total cost required to complete all the task. | [{"input": "1 6 3", "output": "5\n \n\nWhen the tasks are completed in the following order, the total cost will be 5,\nwhich is the minimum:\n\n * Complete the first task at cost 0.\n * Complete the third task at cost 2.\n * Complete the second task at cost 3.\n\n* * *"}, {"input": "11 5 5", "output": "6\n \n\n* * *"}, {"input": "100 100 100", "output": "0"}] |
Print the minimum total cost required to complete all the task.
* * * | s330097912 | Runtime Error | p03292 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | X = map(int, input().split())
print(max(X) - min(X))
| Statement
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 0.
Then, just after completing the i-th task, you can complete the j-th task at
cost |A_j - A_i|.
Here, |x| denotes the absolute value of x.
Find the minimum total cost required to complete all the task. | [{"input": "1 6 3", "output": "5\n \n\nWhen the tasks are completed in the following order, the total cost will be 5,\nwhich is the minimum:\n\n * Complete the first task at cost 0.\n * Complete the third task at cost 2.\n * Complete the second task at cost 3.\n\n* * *"}, {"input": "11 5 5", "output": "6\n \n\n* * *"}, {"input": "100 100 100", "output": "0"}] |
Print the minimum total cost required to complete all the task.
* * * | s605901049 | Runtime Error | p03292 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | A = map(int, input().split())
print(max(A) min(A)) | Statement
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 0.
Then, just after completing the i-th task, you can complete the j-th task at
cost |A_j - A_i|.
Here, |x| denotes the absolute value of x.
Find the minimum total cost required to complete all the task. | [{"input": "1 6 3", "output": "5\n \n\nWhen the tasks are completed in the following order, the total cost will be 5,\nwhich is the minimum:\n\n * Complete the first task at cost 0.\n * Complete the third task at cost 2.\n * Complete the second task at cost 3.\n\n* * *"}, {"input": "11 5 5", "output": "6\n \n\n* * *"}, {"input": "100 100 100", "output": "0"}] |
Print the minimum total cost required to complete all the task.
* * * | s494915210 | Runtime Error | p03292 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | s = sorted(map(int, input().splitu()))
v = s[2] - s[0]
print(v)
| Statement
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 0.
Then, just after completing the i-th task, you can complete the j-th task at
cost |A_j - A_i|.
Here, |x| denotes the absolute value of x.
Find the minimum total cost required to complete all the task. | [{"input": "1 6 3", "output": "5\n \n\nWhen the tasks are completed in the following order, the total cost will be 5,\nwhich is the minimum:\n\n * Complete the first task at cost 0.\n * Complete the third task at cost 2.\n * Complete the second task at cost 3.\n\n* * *"}, {"input": "11 5 5", "output": "6\n \n\n* * *"}, {"input": "100 100 100", "output": "0"}] |
Print the minimum total cost required to complete all the task.
* * * | s675533687 | Runtime Error | p03292 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | a,b,c=sorted(map(int, input().split())
print(a+c) | Statement
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 0.
Then, just after completing the i-th task, you can complete the j-th task at
cost |A_j - A_i|.
Here, |x| denotes the absolute value of x.
Find the minimum total cost required to complete all the task. | [{"input": "1 6 3", "output": "5\n \n\nWhen the tasks are completed in the following order, the total cost will be 5,\nwhich is the minimum:\n\n * Complete the first task at cost 0.\n * Complete the third task at cost 2.\n * Complete the second task at cost 3.\n\n* * *"}, {"input": "11 5 5", "output": "6\n \n\n* * *"}, {"input": "100 100 100", "output": "0"}] |
Print the minimum total cost required to complete all the task.
* * * | s342164228 | Accepted | p03292 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI():
return [int(x) for x in sys.stdin.readline().split()]
def LI_():
return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF():
return [float(x) for x in sys.stdin.readline().split()]
def LS():
return sys.stdin.readline().split()
def I():
return int(sys.stdin.readline())
def F():
return float(sys.stdin.readline())
def S():
return input()
def pf(s):
return print(s, flush=True)
def main():
a = sorted(LI())
return a[-1] - a[0]
print(main())
| Statement
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 0.
Then, just after completing the i-th task, you can complete the j-th task at
cost |A_j - A_i|.
Here, |x| denotes the absolute value of x.
Find the minimum total cost required to complete all the task. | [{"input": "1 6 3", "output": "5\n \n\nWhen the tasks are completed in the following order, the total cost will be 5,\nwhich is the minimum:\n\n * Complete the first task at cost 0.\n * Complete the third task at cost 2.\n * Complete the second task at cost 3.\n\n* * *"}, {"input": "11 5 5", "output": "6\n \n\n* * *"}, {"input": "100 100 100", "output": "0"}] |
Print the minimum total cost required to complete all the task.
* * * | s310669877 | Accepted | p03292 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | a = list(map(int, input().split()))
ans = [10**8] * 6
ans[0] = abs(a[1] - a[0]) + abs(a[2] - a[1])
ans[1] = abs(a[2] - a[0]) + abs(a[1] - a[2])
ans[2] = abs(a[0] - a[1]) + abs(a[2] - a[0])
ans[3] = abs(a[2] - a[1]) + abs(a[0] - a[2])
ans[4] = abs(a[0] - a[2]) + abs(a[1] - a[0])
ans[5] = abs(a[1] - a[2]) + abs(a[0] - a[1])
print(min(ans))
| Statement
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 0.
Then, just after completing the i-th task, you can complete the j-th task at
cost |A_j - A_i|.
Here, |x| denotes the absolute value of x.
Find the minimum total cost required to complete all the task. | [{"input": "1 6 3", "output": "5\n \n\nWhen the tasks are completed in the following order, the total cost will be 5,\nwhich is the minimum:\n\n * Complete the first task at cost 0.\n * Complete the third task at cost 2.\n * Complete the second task at cost 3.\n\n* * *"}, {"input": "11 5 5", "output": "6\n \n\n* * *"}, {"input": "100 100 100", "output": "0"}] |
Print the minimum total cost required to complete all the task.
* * * | s982110777 | Accepted | p03292 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | ###############################################################################
from sys import stdout
from bisect import bisect_left as binl
from copy import copy, deepcopy
from collections import defaultdict
mod = 1
def intin():
input_tuple = input().split()
if len(input_tuple) <= 1:
return int(input_tuple[0])
return tuple(map(int, input_tuple))
def intina():
return [int(i) for i in input().split()]
def intinl(count):
return [intin() for _ in range(count)]
def modadd(x, y):
global mod
return (x + y) % mod
def modmlt(x, y):
global mod
return (x * y) % mod
def lcm(x, y):
while y != 0:
z = x % y
x = y
y = z
return x
def combination(x, y):
assert x >= y
if y > x // 2:
y = x - y
ret = 1
for i in range(0, y):
j = x - i
i = i + 1
ret = ret * j
ret = ret // i
return ret
def get_divisors(x):
retlist = []
for i in range(1, int(x**0.5) + 3):
if x % i == 0:
retlist.append(i)
retlist.append(x // i)
return retlist
def get_factors(x):
retlist = []
for i in range(2, int(x**0.5) + 3):
while x % i == 0:
retlist.append(i)
x = x // i
retlist.append(x)
return retlist
def make_linklist(xylist):
linklist = {}
for a, b in xylist:
linklist.setdefault(a, [])
linklist.setdefault(b, [])
linklist[a].append(b)
linklist[b].append(a)
return linklist
def calc_longest_distance(linklist, v=1):
distance_list = {}
distance_count = 0
distance = 0
vlist_previous = []
vlist = [v]
nodecount = len(linklist)
while distance_count < nodecount:
vlist_next = []
for v in vlist:
distance_list[v] = distance
distance_count += 1
vlist_next.extend(linklist[v])
distance += 1
vlist_to_del = vlist_previous
vlist_previous = vlist
vlist = list(set(vlist_next) - set(vlist_to_del))
max_distance = -1
max_v = None
for v, distance in distance_list.items():
if distance > max_distance:
max_distance = distance
max_v = v
return (max_distance, max_v)
def calc_tree_diameter(linklist, v=1):
_, u = calc_longest_distance(linklist, v)
distance, _ = calc_longest_distance(linklist, u)
return distance
###############################################################################
def main():
a1, a2, a3 = intin()
a12 = abs(a1 - a2)
a23 = abs(a2 - a3)
a31 = abs(a3 - a1)
mina = min(a12 + a23, a23 + a31)
mina = min(mina, a31 + a12)
print(mina)
if __name__ == "__main__":
main()
| Statement
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 0.
Then, just after completing the i-th task, you can complete the j-th task at
cost |A_j - A_i|.
Here, |x| denotes the absolute value of x.
Find the minimum total cost required to complete all the task. | [{"input": "1 6 3", "output": "5\n \n\nWhen the tasks are completed in the following order, the total cost will be 5,\nwhich is the minimum:\n\n * Complete the first task at cost 0.\n * Complete the third task at cost 2.\n * Complete the second task at cost 3.\n\n* * *"}, {"input": "11 5 5", "output": "6\n \n\n* * *"}, {"input": "100 100 100", "output": "0"}] |
Print the minimum total cost required to complete all the task.
* * * | s401519537 | Accepted | p03292 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | A1, A2, A3 = map(int, input().split())
res = 100 * 3
A = [A1, A2, A3]
arr = [[0, 1, 2], [0, 2, 1], [1, 0, 2], [1, 2, 0], [2, 0, 1], [2, 1, 0]]
for a in arr:
m = abs(A[a[0]] - A[a[1]])
n = abs(A[a[2]] - A[a[1]])
if res > m + n:
res = m + n
print(res)
| Statement
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 0.
Then, just after completing the i-th task, you can complete the j-th task at
cost |A_j - A_i|.
Here, |x| denotes the absolute value of x.
Find the minimum total cost required to complete all the task. | [{"input": "1 6 3", "output": "5\n \n\nWhen the tasks are completed in the following order, the total cost will be 5,\nwhich is the minimum:\n\n * Complete the first task at cost 0.\n * Complete the third task at cost 2.\n * Complete the second task at cost 3.\n\n* * *"}, {"input": "11 5 5", "output": "6\n \n\n* * *"}, {"input": "100 100 100", "output": "0"}] |
Print the minimum total cost required to complete all the task.
* * * | s321909025 | Accepted | p03292 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | #!/usr/bin/env python3
import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop, heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float("inf")
def I():
return int(sys.stdin.readline())
def LI():
return list(map(int, sys.stdin.readline().split()))
a = LI()
a.sort(reverse=1)
ans = a[0] - a[2]
print(ans)
| Statement
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 0.
Then, just after completing the i-th task, you can complete the j-th task at
cost |A_j - A_i|.
Here, |x| denotes the absolute value of x.
Find the minimum total cost required to complete all the task. | [{"input": "1 6 3", "output": "5\n \n\nWhen the tasks are completed in the following order, the total cost will be 5,\nwhich is the minimum:\n\n * Complete the first task at cost 0.\n * Complete the third task at cost 2.\n * Complete the second task at cost 3.\n\n* * *"}, {"input": "11 5 5", "output": "6\n \n\n* * *"}, {"input": "100 100 100", "output": "0"}] |
Print the minimum total cost required to complete all the task.
* * * | s046085656 | Runtime Error | p03292 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | a = list(map(int,input().split()))
k = max(abs(a[0]-a[1]),abs(a[1]-a[2]),abs(a[2]-a[1]))
print(abs(a[0]-a[1])+abs(a[1]-a[2])+abs(a[2]-a[0])-k | Statement
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 0.
Then, just after completing the i-th task, you can complete the j-th task at
cost |A_j - A_i|.
Here, |x| denotes the absolute value of x.
Find the minimum total cost required to complete all the task. | [{"input": "1 6 3", "output": "5\n \n\nWhen the tasks are completed in the following order, the total cost will be 5,\nwhich is the minimum:\n\n * Complete the first task at cost 0.\n * Complete the third task at cost 2.\n * Complete the second task at cost 3.\n\n* * *"}, {"input": "11 5 5", "output": "6\n \n\n* * *"}, {"input": "100 100 100", "output": "0"}] |
Print the minimum total cost required to complete all the task.
* * * | s025211218 | Runtime Error | p03292 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | ar=[int(i) for i in input().strip().split(" ")]
ar.sort()
s=0
for i in range(1,len(ar)):
s+=(ar[i]-ar[i-1])
print(s) | Statement
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 0.
Then, just after completing the i-th task, you can complete the j-th task at
cost |A_j - A_i|.
Here, |x| denotes the absolute value of x.
Find the minimum total cost required to complete all the task. | [{"input": "1 6 3", "output": "5\n \n\nWhen the tasks are completed in the following order, the total cost will be 5,\nwhich is the minimum:\n\n * Complete the first task at cost 0.\n * Complete the third task at cost 2.\n * Complete the second task at cost 3.\n\n* * *"}, {"input": "11 5 5", "output": "6\n \n\n* * *"}, {"input": "100 100 100", "output": "0"}] |
Print the minimum total cost required to complete all the task.
* * * | s587364103 | Runtime Error | p03292 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | a = list(map(int, input().split()))
b = [0] * a[0]
for i in range(a[1]):
m, n = map(int, input().split())
b[m - 1] += 1
b[n - 1] -= 1
ma = b[0]
for i in range(1, a[0]):
b[i] += b[i - 1]
if b[i] >= ma:
ma = b[i]
k = i
print(a[1] - ma + 1)
| Statement
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 0.
Then, just after completing the i-th task, you can complete the j-th task at
cost |A_j - A_i|.
Here, |x| denotes the absolute value of x.
Find the minimum total cost required to complete all the task. | [{"input": "1 6 3", "output": "5\n \n\nWhen the tasks are completed in the following order, the total cost will be 5,\nwhich is the minimum:\n\n * Complete the first task at cost 0.\n * Complete the third task at cost 2.\n * Complete the second task at cost 3.\n\n* * *"}, {"input": "11 5 5", "output": "6\n \n\n* * *"}, {"input": "100 100 100", "output": "0"}] |
Print the minimum total cost required to complete all the task.
* * * | s864830337 | Accepted | p03292 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | data = list(map(int, input().split()))
data.sort(reverse=True)
print(data[0] - data[1] + data[1] - data[2])
| Statement
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 0.
Then, just after completing the i-th task, you can complete the j-th task at
cost |A_j - A_i|.
Here, |x| denotes the absolute value of x.
Find the minimum total cost required to complete all the task. | [{"input": "1 6 3", "output": "5\n \n\nWhen the tasks are completed in the following order, the total cost will be 5,\nwhich is the minimum:\n\n * Complete the first task at cost 0.\n * Complete the third task at cost 2.\n * Complete the second task at cost 3.\n\n* * *"}, {"input": "11 5 5", "output": "6\n \n\n* * *"}, {"input": "100 100 100", "output": "0"}] |
Print the minimum total cost required to complete all the task.
* * * | s980214423 | Runtime Error | p03292 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | main = do
xs <- map read . words $ getLine :: IO [Int]
putStrLn . show $ (maximum xs) - (minimum xs) | Statement
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 0.
Then, just after completing the i-th task, you can complete the j-th task at
cost |A_j - A_i|.
Here, |x| denotes the absolute value of x.
Find the minimum total cost required to complete all the task. | [{"input": "1 6 3", "output": "5\n \n\nWhen the tasks are completed in the following order, the total cost will be 5,\nwhich is the minimum:\n\n * Complete the first task at cost 0.\n * Complete the third task at cost 2.\n * Complete the second task at cost 3.\n\n* * *"}, {"input": "11 5 5", "output": "6\n \n\n* * *"}, {"input": "100 100 100", "output": "0"}] |
Print the minimum total cost required to complete all the task.
* * * | s893002048 | Runtime Error | p03292 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | main = do
xs <- map read . words <$> getLine :: IO [Int]
putStrLn . show $ (maximum xs) - (minimum xs) | Statement
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 0.
Then, just after completing the i-th task, you can complete the j-th task at
cost |A_j - A_i|.
Here, |x| denotes the absolute value of x.
Find the minimum total cost required to complete all the task. | [{"input": "1 6 3", "output": "5\n \n\nWhen the tasks are completed in the following order, the total cost will be 5,\nwhich is the minimum:\n\n * Complete the first task at cost 0.\n * Complete the third task at cost 2.\n * Complete the second task at cost 3.\n\n* * *"}, {"input": "11 5 5", "output": "6\n \n\n* * *"}, {"input": "100 100 100", "output": "0"}] |
Print the minimum total cost required to complete all the task.
* * * | s928092999 | Accepted | p03292 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | Als = list(map(int, input().split()))
Als.sort()
print(Als[2] - Als[0])
| Statement
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 0.
Then, just after completing the i-th task, you can complete the j-th task at
cost |A_j - A_i|.
Here, |x| denotes the absolute value of x.
Find the minimum total cost required to complete all the task. | [{"input": "1 6 3", "output": "5\n \n\nWhen the tasks are completed in the following order, the total cost will be 5,\nwhich is the minimum:\n\n * Complete the first task at cost 0.\n * Complete the third task at cost 2.\n * Complete the second task at cost 3.\n\n* * *"}, {"input": "11 5 5", "output": "6\n \n\n* * *"}, {"input": "100 100 100", "output": "0"}] |
Print the minimum total cost required to complete all the task.
* * * | s442814049 | Accepted | p03292 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | x = sorted(map(int, input().split()))
print(abs(x[0] - x[1]) + abs(x[1] - x[2]))
| Statement
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 0.
Then, just after completing the i-th task, you can complete the j-th task at
cost |A_j - A_i|.
Here, |x| denotes the absolute value of x.
Find the minimum total cost required to complete all the task. | [{"input": "1 6 3", "output": "5\n \n\nWhen the tasks are completed in the following order, the total cost will be 5,\nwhich is the minimum:\n\n * Complete the first task at cost 0.\n * Complete the third task at cost 2.\n * Complete the second task at cost 3.\n\n* * *"}, {"input": "11 5 5", "output": "6\n \n\n* * *"}, {"input": "100 100 100", "output": "0"}] |
Print the minimum total cost required to complete all the task.
* * * | s411158367 | Runtime Error | p03292 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | N_List = sorted(list(map(int, input().split())))
print(sum(N_List[1:] - N_List[:-1]))
| Statement
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 0.
Then, just after completing the i-th task, you can complete the j-th task at
cost |A_j - A_i|.
Here, |x| denotes the absolute value of x.
Find the minimum total cost required to complete all the task. | [{"input": "1 6 3", "output": "5\n \n\nWhen the tasks are completed in the following order, the total cost will be 5,\nwhich is the minimum:\n\n * Complete the first task at cost 0.\n * Complete the third task at cost 2.\n * Complete the second task at cost 3.\n\n* * *"}, {"input": "11 5 5", "output": "6\n \n\n* * *"}, {"input": "100 100 100", "output": "0"}] |
Print the minimum total cost required to complete all the task.
* * * | s050586132 | Runtime Error | p03292 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | list = input()
list_n = [int(s) for s in list]
print(max(list_n) - min(list_n))
| Statement
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 0.
Then, just after completing the i-th task, you can complete the j-th task at
cost |A_j - A_i|.
Here, |x| denotes the absolute value of x.
Find the minimum total cost required to complete all the task. | [{"input": "1 6 3", "output": "5\n \n\nWhen the tasks are completed in the following order, the total cost will be 5,\nwhich is the minimum:\n\n * Complete the first task at cost 0.\n * Complete the third task at cost 2.\n * Complete the second task at cost 3.\n\n* * *"}, {"input": "11 5 5", "output": "6\n \n\n* * *"}, {"input": "100 100 100", "output": "0"}] |
Print the minimum total cost required to complete all the task.
* * * | s021029297 | Runtime Error | p03292 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | a = list(map(int, input().split()))
a.sort()
print(abs(a[0]-a[1]) + abs(a[1]-a[2]) | Statement
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 0.
Then, just after completing the i-th task, you can complete the j-th task at
cost |A_j - A_i|.
Here, |x| denotes the absolute value of x.
Find the minimum total cost required to complete all the task. | [{"input": "1 6 3", "output": "5\n \n\nWhen the tasks are completed in the following order, the total cost will be 5,\nwhich is the minimum:\n\n * Complete the first task at cost 0.\n * Complete the third task at cost 2.\n * Complete the second task at cost 3.\n\n* * *"}, {"input": "11 5 5", "output": "6\n \n\n* * *"}, {"input": "100 100 100", "output": "0"}] |
Print the minimum total cost required to complete all the task.
* * * | s211389231 | Runtime Error | p03292 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | a* = map(int, input().split())
print(max(a) - min(a)) | Statement
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 0.
Then, just after completing the i-th task, you can complete the j-th task at
cost |A_j - A_i|.
Here, |x| denotes the absolute value of x.
Find the minimum total cost required to complete all the task. | [{"input": "1 6 3", "output": "5\n \n\nWhen the tasks are completed in the following order, the total cost will be 5,\nwhich is the minimum:\n\n * Complete the first task at cost 0.\n * Complete the third task at cost 2.\n * Complete the second task at cost 3.\n\n* * *"}, {"input": "11 5 5", "output": "6\n \n\n* * *"}, {"input": "100 100 100", "output": "0"}] |
Print the minimum total cost required to complete all the task.
* * * | s548624544 | Wrong Answer | p03292 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | list_task = list(map(int, input().split()))
N = len(list_task)
# ใฝใผใใซใใฃใฆใชในใใ้้
list_task.reverse()
# ๆๅใฎใณในใใฏ0ใชใฎใงๆๅคงๅคใๅ้คใใใใใๆฌกใฎ่จ็ฎใฎใใใซๅคๆฐใซๆ ผ็ด
total_cost = 0
last_number = list_task[0]
list_task.pop(0)
for i in list_task:
total_cost += last_number - i
last_number = i
print(total_cost)
| Statement
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 0.
Then, just after completing the i-th task, you can complete the j-th task at
cost |A_j - A_i|.
Here, |x| denotes the absolute value of x.
Find the minimum total cost required to complete all the task. | [{"input": "1 6 3", "output": "5\n \n\nWhen the tasks are completed in the following order, the total cost will be 5,\nwhich is the minimum:\n\n * Complete the first task at cost 0.\n * Complete the third task at cost 2.\n * Complete the second task at cost 3.\n\n* * *"}, {"input": "11 5 5", "output": "6\n \n\n* * *"}, {"input": "100 100 100", "output": "0"}] |
Print the minimum total cost required to complete all the task.
* * * | s810405918 | Runtime Error | p03292 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | a = list(map(int, input().split()))
a.sort()
ans = 0:
for i in range(1, 3):
ans += abs(a[i] - a[i - 1])
print(ans) | Statement
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 0.
Then, just after completing the i-th task, you can complete the j-th task at
cost |A_j - A_i|.
Here, |x| denotes the absolute value of x.
Find the minimum total cost required to complete all the task. | [{"input": "1 6 3", "output": "5\n \n\nWhen the tasks are completed in the following order, the total cost will be 5,\nwhich is the minimum:\n\n * Complete the first task at cost 0.\n * Complete the third task at cost 2.\n * Complete the second task at cost 3.\n\n* * *"}, {"input": "11 5 5", "output": "6\n \n\n* * *"}, {"input": "100 100 100", "output": "0"}] |
Print the minimum total cost required to complete all the task.
* * * | s135567932 | Accepted | p03292 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | Alist = list(map(int, input().split()))
p = [0, 0, 0, 0, 0, 0]
p[0] = abs(Alist[0] - Alist[1]) + abs(Alist[1] - Alist[2])
p[1] = abs(Alist[0] - Alist[2]) + abs(Alist[1] - Alist[2])
p[2] = abs(Alist[1] - Alist[2]) + abs(Alist[0] - Alist[2])
p[3] = abs(Alist[1] - Alist[0]) + abs(Alist[0] - Alist[2])
p[4] = abs(Alist[0] - Alist[2]) + abs(Alist[1] - Alist[0])
p[5] = abs(Alist[2] - Alist[1]) + abs(Alist[1] - Alist[0])
print(min(p))
| Statement
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 0.
Then, just after completing the i-th task, you can complete the j-th task at
cost |A_j - A_i|.
Here, |x| denotes the absolute value of x.
Find the minimum total cost required to complete all the task. | [{"input": "1 6 3", "output": "5\n \n\nWhen the tasks are completed in the following order, the total cost will be 5,\nwhich is the minimum:\n\n * Complete the first task at cost 0.\n * Complete the third task at cost 2.\n * Complete the second task at cost 3.\n\n* * *"}, {"input": "11 5 5", "output": "6\n \n\n* * *"}, {"input": "100 100 100", "output": "0"}] |
Print the minimum total cost required to complete all the task.
* * * | s009524137 | Accepted | p03292 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | a = list(map(int, input().split()))
b1 = abs(a[0] - a[1]) + abs(a[1] - a[2])
b2 = abs(a[0] - a[2]) + abs(a[2] - a[1])
b3 = abs(a[1] - a[0]) + abs(a[0] - a[2])
b4 = abs(a[1] - a[2]) + abs(a[0] - a[2])
b5 = abs(a[2] - a[0]) + abs(a[0] - a[1])
b6 = abs(a[2] - a[1]) + abs(a[0] - a[1])
ans = min(b1, b2, b3, b4, b5, b6)
print(ans)
| Statement
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 0.
Then, just after completing the i-th task, you can complete the j-th task at
cost |A_j - A_i|.
Here, |x| denotes the absolute value of x.
Find the minimum total cost required to complete all the task. | [{"input": "1 6 3", "output": "5\n \n\nWhen the tasks are completed in the following order, the total cost will be 5,\nwhich is the minimum:\n\n * Complete the first task at cost 0.\n * Complete the third task at cost 2.\n * Complete the second task at cost 3.\n\n* * *"}, {"input": "11 5 5", "output": "6\n \n\n* * *"}, {"input": "100 100 100", "output": "0"}] |
Print the minimum total cost required to complete all the task.
* * * | s976460747 | Accepted | p03292 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | a, b, c = map(int, input().split())
p = abs(a - b) + abs(c - b)
q = abs(a - c) + abs(c - b)
b1 = abs(b - a) + abs(a - c)
b2 = abs(b - c) + abs(c - a)
c1 = abs(a - c) + abs(b - a)
c2 = abs(b - c) + abs(b - a)
rec = min(p, q)
rec = min(rec, min(b1, b2))
rec = min(rec, min(c1, c2))
print(rec)
| Statement
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 0.
Then, just after completing the i-th task, you can complete the j-th task at
cost |A_j - A_i|.
Here, |x| denotes the absolute value of x.
Find the minimum total cost required to complete all the task. | [{"input": "1 6 3", "output": "5\n \n\nWhen the tasks are completed in the following order, the total cost will be 5,\nwhich is the minimum:\n\n * Complete the first task at cost 0.\n * Complete the third task at cost 2.\n * Complete the second task at cost 3.\n\n* * *"}, {"input": "11 5 5", "output": "6\n \n\n* * *"}, {"input": "100 100 100", "output": "0"}] |
Print the minimum total cost required to complete all the task.
* * * | s426021071 | Accepted | p03292 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | a, b, c = map(int, input().split())
i = abs(a - b) + abs(b - c)
i2 = abs(a - c) + abs(b - c)
j = abs(a - b) + abs(a - c)
j2 = abs(c - b) + abs(a - c)
k = abs(a - c) + abs(b - a)
k2 = abs(c - b) + abs(b - a)
n = min(i, i2, j, j2, k, k2)
print(n)
| Statement
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 0.
Then, just after completing the i-th task, you can complete the j-th task at
cost |A_j - A_i|.
Here, |x| denotes the absolute value of x.
Find the minimum total cost required to complete all the task. | [{"input": "1 6 3", "output": "5\n \n\nWhen the tasks are completed in the following order, the total cost will be 5,\nwhich is the minimum:\n\n * Complete the first task at cost 0.\n * Complete the third task at cost 2.\n * Complete the second task at cost 3.\n\n* * *"}, {"input": "11 5 5", "output": "6\n \n\n* * *"}, {"input": "100 100 100", "output": "0"}] |
Print the minimum total cost required to complete all the task.
* * * | s076799385 | Runtime Error | p03292 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | N, M = list(map(int, input().split(" ")))
edges = []
for i in range(M):
a, b = list(map(int, input().split(" ")))
edges.append([v for v in range(a, b)])
ans = 0
while any(edges):
hit_index = 0
max_hit = 0
edge = []
for i in range(len(edges)):
if edges[i]:
edge = edges[i]
break
for v in edge[::-1]:
hit = 0
for i in range(M):
if edges[i] and v in edges[i]:
hit += 1
if hit > max_hit:
max_hit = hit
hit_index = v
# print('max_hit')
# print(max_hit)
# print('cut here')
# print(hit_index)
for i in range(len(edges)):
if edges[i] and hit_index in edges[i]:
edges[i] = False
ans += 1
# print('cutted')
# print(edges)
print(ans)
| Statement
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 0.
Then, just after completing the i-th task, you can complete the j-th task at
cost |A_j - A_i|.
Here, |x| denotes the absolute value of x.
Find the minimum total cost required to complete all the task. | [{"input": "1 6 3", "output": "5\n \n\nWhen the tasks are completed in the following order, the total cost will be 5,\nwhich is the minimum:\n\n * Complete the first task at cost 0.\n * Complete the third task at cost 2.\n * Complete the second task at cost 3.\n\n* * *"}, {"input": "11 5 5", "output": "6\n \n\n* * *"}, {"input": "100 100 100", "output": "0"}] |
Print the minimum total cost required to complete all the task.
* * * | s096218774 | Runtime Error | p03292 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | task = [int(i) for i in input.split(" ")]
ans = 5000
if abs(task[0] - task[1]) + abs(task[2] - task[0]) < ans:
ans = abs(task[0] - task[1]) + abs(task[2] - task[0])
if abs(task[0] - task[2]) + abs(task[1] - task[0]) < ans:
ans = abs(task[0] - task[2]) + abs(task[1] - task[0])
if abs(task[1] - task[0]) + abs(task[2] - task[1]) < ans:
ans = abs(task[1] - task[0]) + abs(task[2] - task[1])
if abs(task[1] - task[2]) + abs(task[0] - task[1]) < ans:
ans = abs(task[1] - task[2]) + abs(task[0] - task[1])
if abs(task[2] - task[0]) + abs(task[1] - task[2]) < ans:
ans = abs(task[2] - task[0]) + abs(task[1] - task[2])
if abs(task[2] - task[1]) + abs(task[0] - task[2]) < ans:
ans = abs(task[2] - task[1]) + abs(task[0] - task[2])
print(ans)
| Statement
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 0.
Then, just after completing the i-th task, you can complete the j-th task at
cost |A_j - A_i|.
Here, |x| denotes the absolute value of x.
Find the minimum total cost required to complete all the task. | [{"input": "1 6 3", "output": "5\n \n\nWhen the tasks are completed in the following order, the total cost will be 5,\nwhich is the minimum:\n\n * Complete the first task at cost 0.\n * Complete the third task at cost 2.\n * Complete the second task at cost 3.\n\n* * *"}, {"input": "11 5 5", "output": "6\n \n\n* * *"}, {"input": "100 100 100", "output": "0"}] |
Print the minimum total cost required to complete all the task.
* * * | s865089342 | Runtime Error | p03292 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | class Need(object):
def __init__(self, arg1, arg2):
self.island1 = int(arg1)
self.island2 = int(arg2)
self.bridge = []
for i in range(arg1, arg2):
self.bridge.append(i)
def GETbridge(self):
return self.bridge
deadbridges = 0
islands, needsnum = map(int, input().split())
bridge = [0 for _ in range(islands - 1)]
box = []
for i in range(needsnum):
arg1, arg2 = map(int, input().split())
box.append(Need(arg1, arg2))
# ใใใใๆ็ฅจใใใใ
while len(box) != 1:
bridge = [0 for _ in range(islands - 1)]
for need in box:
list = need.GETbridge()
for ing in list:
bridge[ing - 1] = bridge[ing - 1] + 1
# ้่จ็ตใใ
maxi = 0
for i in range(len(bridge)):
if bridge[i] > bridge[maxi]:
maxi = i
# ๆฉใๅ้ค
deadbridges = deadbridges + 1
# ่ฆๆใๅ้ค
kill = False
for i in range(len(box)):
try:
s = box[i].GETbridge()
except:
break
for k in s:
if k == bridge[maxi]:
kill = True
break
if kill:
box.pop(i)
i = i - 1
print(deadbridges)
| Statement
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 0.
Then, just after completing the i-th task, you can complete the j-th task at
cost |A_j - A_i|.
Here, |x| denotes the absolute value of x.
Find the minimum total cost required to complete all the task. | [{"input": "1 6 3", "output": "5\n \n\nWhen the tasks are completed in the following order, the total cost will be 5,\nwhich is the minimum:\n\n * Complete the first task at cost 0.\n * Complete the third task at cost 2.\n * Complete the second task at cost 3.\n\n* * *"}, {"input": "11 5 5", "output": "6\n \n\n* * *"}, {"input": "100 100 100", "output": "0"}] |
Print the minimum total cost required to complete all the task.
* * * | s969006718 | Runtime Error | p03292 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | n, m = map(int, input().split())
# ab = [list(map(int, input().split())) for _ in range(m)]
ranges = [[] for _ in range(m)]
for i in range(m):
a, b = map(int, input().split())
ranges[i] = [a, b]
ranges = sorted(ranges, key=lambda x: x[1])
MAX = -float("inf")
ans = 0 # ๏ผใคใใฏใใผใซใณ
for i in range(m):
if MAX < ranges[i][0]:
MAX = ranges[i][0] - 0.1
ans += 1
print(ans)
| Statement
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 0.
Then, just after completing the i-th task, you can complete the j-th task at
cost |A_j - A_i|.
Here, |x| denotes the absolute value of x.
Find the minimum total cost required to complete all the task. | [{"input": "1 6 3", "output": "5\n \n\nWhen the tasks are completed in the following order, the total cost will be 5,\nwhich is the minimum:\n\n * Complete the first task at cost 0.\n * Complete the third task at cost 2.\n * Complete the second task at cost 3.\n\n* * *"}, {"input": "11 5 5", "output": "6\n \n\n* * *"}, {"input": "100 100 100", "output": "0"}] |
Print the minimum total cost required to complete all the task.
* * * | s592133962 | Accepted | p03292 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | n = sorted(map(int, input().split()))
print(n[2] - n[0])
| Statement
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 0.
Then, just after completing the i-th task, you can complete the j-th task at
cost |A_j - A_i|.
Here, |x| denotes the absolute value of x.
Find the minimum total cost required to complete all the task. | [{"input": "1 6 3", "output": "5\n \n\nWhen the tasks are completed in the following order, the total cost will be 5,\nwhich is the minimum:\n\n * Complete the first task at cost 0.\n * Complete the third task at cost 2.\n * Complete the second task at cost 3.\n\n* * *"}, {"input": "11 5 5", "output": "6\n \n\n* * *"}, {"input": "100 100 100", "output": "0"}] |
Print the minimum total cost required to complete all the task.
* * * | s493746463 | Runtime Error | p03292 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | Not found | Statement
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 0.
Then, just after completing the i-th task, you can complete the j-th task at
cost |A_j - A_i|.
Here, |x| denotes the absolute value of x.
Find the minimum total cost required to complete all the task. | [{"input": "1 6 3", "output": "5\n \n\nWhen the tasks are completed in the following order, the total cost will be 5,\nwhich is the minimum:\n\n * Complete the first task at cost 0.\n * Complete the third task at cost 2.\n * Complete the second task at cost 3.\n\n* * *"}, {"input": "11 5 5", "output": "6\n \n\n* * *"}, {"input": "100 100 100", "output": "0"}] |
Print the minimum total cost required to complete all the task.
* * * | s506045699 | Runtime Error | p03292 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | x = map(int, input().split())
print(max(x) - min(x))
| Statement
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 0.
Then, just after completing the i-th task, you can complete the j-th task at
cost |A_j - A_i|.
Here, |x| denotes the absolute value of x.
Find the minimum total cost required to complete all the task. | [{"input": "1 6 3", "output": "5\n \n\nWhen the tasks are completed in the following order, the total cost will be 5,\nwhich is the minimum:\n\n * Complete the first task at cost 0.\n * Complete the third task at cost 2.\n * Complete the second task at cost 3.\n\n* * *"}, {"input": "11 5 5", "output": "6\n \n\n* * *"}, {"input": "100 100 100", "output": "0"}] |
Print the minimum total cost required to complete all the task.
* * * | s071247645 | Runtime Error | p03292 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | s=list(map(int,input())
s=s.sort()
print(s[1]-s[0])
| Statement
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 0.
Then, just after completing the i-th task, you can complete the j-th task at
cost |A_j - A_i|.
Here, |x| denotes the absolute value of x.
Find the minimum total cost required to complete all the task. | [{"input": "1 6 3", "output": "5\n \n\nWhen the tasks are completed in the following order, the total cost will be 5,\nwhich is the minimum:\n\n * Complete the first task at cost 0.\n * Complete the third task at cost 2.\n * Complete the second task at cost 3.\n\n* * *"}, {"input": "11 5 5", "output": "6\n \n\n* * *"}, {"input": "100 100 100", "output": "0"}] |
Print the minimum total cost required to complete all the task.
* * * | s849456992 | Wrong Answer | p03292 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | As = input().split()
print(int(max(As)) - int(min(As)))
| Statement
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 0.
Then, just after completing the i-th task, you can complete the j-th task at
cost |A_j - A_i|.
Here, |x| denotes the absolute value of x.
Find the minimum total cost required to complete all the task. | [{"input": "1 6 3", "output": "5\n \n\nWhen the tasks are completed in the following order, the total cost will be 5,\nwhich is the minimum:\n\n * Complete the first task at cost 0.\n * Complete the third task at cost 2.\n * Complete the second task at cost 3.\n\n* * *"}, {"input": "11 5 5", "output": "6\n \n\n* * *"}, {"input": "100 100 100", "output": "0"}] |
Print the minimum total cost required to complete all the task.
* * * | s105847107 | Runtime Error | p03292 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | A,B,C=map(int,input().split())
print(max(A,B,C)-min(A,B,C) | Statement
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 0.
Then, just after completing the i-th task, you can complete the j-th task at
cost |A_j - A_i|.
Here, |x| denotes the absolute value of x.
Find the minimum total cost required to complete all the task. | [{"input": "1 6 3", "output": "5\n \n\nWhen the tasks are completed in the following order, the total cost will be 5,\nwhich is the minimum:\n\n * Complete the first task at cost 0.\n * Complete the third task at cost 2.\n * Complete the second task at cost 3.\n\n* * *"}, {"input": "11 5 5", "output": "6\n \n\n* * *"}, {"input": "100 100 100", "output": "0"}] |
Print the minimum total cost required to complete all the task.
* * * | s450251156 | Runtime Error | p03292 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | s = list(int(input()))
s = s.sorted()
print(s[1] - s[0])
| Statement
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 0.
Then, just after completing the i-th task, you can complete the j-th task at
cost |A_j - A_i|.
Here, |x| denotes the absolute value of x.
Find the minimum total cost required to complete all the task. | [{"input": "1 6 3", "output": "5\n \n\nWhen the tasks are completed in the following order, the total cost will be 5,\nwhich is the minimum:\n\n * Complete the first task at cost 0.\n * Complete the third task at cost 2.\n * Complete the second task at cost 3.\n\n* * *"}, {"input": "11 5 5", "output": "6\n \n\n* * *"}, {"input": "100 100 100", "output": "0"}] |
Print the minimum total cost required to complete all the task.
* * * | s689040290 | Accepted | p03292 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | # -*- coding: utf-8 -*-
# ----------
A_list = list(map(int, input().rstrip().split()))
# ----------
A_list.sort()
min_cost = A_list[-1] * A_list[-1]
for i, i_v in enumerate(A_list):
A_list_i = A_list[:]
del A_list_i[i]
for j, j_v in enumerate(A_list_i):
A_list_j = A_list_i[:]
del A_list_j[j]
for k, k_v in enumerate(A_list_j):
cost = abs(j_v - i_v) + abs(k_v - j_v)
if cost < min_cost:
min_cost = cost
print(min_cost)
| Statement
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 0.
Then, just after completing the i-th task, you can complete the j-th task at
cost |A_j - A_i|.
Here, |x| denotes the absolute value of x.
Find the minimum total cost required to complete all the task. | [{"input": "1 6 3", "output": "5\n \n\nWhen the tasks are completed in the following order, the total cost will be 5,\nwhich is the minimum:\n\n * Complete the first task at cost 0.\n * Complete the third task at cost 2.\n * Complete the second task at cost 3.\n\n* * *"}, {"input": "11 5 5", "output": "6\n \n\n* * *"}, {"input": "100 100 100", "output": "0"}] |
Print the minimum total cost required to complete all the task.
* * * | s710472400 | Accepted | p03292 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | Aa, Ab, Ac = map(int, input().split())
li = []
li.append(Aa)
li.append(Ab)
li.append(Ac)
li.sort()
print(abs(li[0] - li[1]) + abs(li[1] - li[2]))
| Statement
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 0.
Then, just after completing the i-th task, you can complete the j-th task at
cost |A_j - A_i|.
Here, |x| denotes the absolute value of x.
Find the minimum total cost required to complete all the task. | [{"input": "1 6 3", "output": "5\n \n\nWhen the tasks are completed in the following order, the total cost will be 5,\nwhich is the minimum:\n\n * Complete the first task at cost 0.\n * Complete the third task at cost 2.\n * Complete the second task at cost 3.\n\n* * *"}, {"input": "11 5 5", "output": "6\n \n\n* * *"}, {"input": "100 100 100", "output": "0"}] |
Print the minimum total cost required to complete all the task.
* * * | s663771292 | Runtime Error | p03292 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | a = list(map(int, input().split()))
print(min([abs(a[0]-a[1])+abs(a[1]-a[2]), abs(a[0]-a[2])+abs(a[1]-a[0])), abs(a[0]-a[2])+abs(a[1]-a[2])]))
| Statement
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 0.
Then, just after completing the i-th task, you can complete the j-th task at
cost |A_j - A_i|.
Here, |x| denotes the absolute value of x.
Find the minimum total cost required to complete all the task. | [{"input": "1 6 3", "output": "5\n \n\nWhen the tasks are completed in the following order, the total cost will be 5,\nwhich is the minimum:\n\n * Complete the first task at cost 0.\n * Complete the third task at cost 2.\n * Complete the second task at cost 3.\n\n* * *"}, {"input": "11 5 5", "output": "6\n \n\n* * *"}, {"input": "100 100 100", "output": "0"}] |
Print the minimum total cost required to complete all the task.
* * * | s662395908 | Runtime Error | p03292 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | a, b, c = map(int, input().split())
if abs(a - b) < abs(a - c) and abs(a - b) < abs(b - c):
print(abs(a - b) + abs(b - c))
elif abs(a - c) < abs(a - b) and abs(a - c) < abs(b - c):
print(abs(a - b) + abs(b - c)
else:
print(abs(b - c) + abs(c - a))
| Statement
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 0.
Then, just after completing the i-th task, you can complete the j-th task at
cost |A_j - A_i|.
Here, |x| denotes the absolute value of x.
Find the minimum total cost required to complete all the task. | [{"input": "1 6 3", "output": "5\n \n\nWhen the tasks are completed in the following order, the total cost will be 5,\nwhich is the minimum:\n\n * Complete the first task at cost 0.\n * Complete the third task at cost 2.\n * Complete the second task at cost 3.\n\n* * *"}, {"input": "11 5 5", "output": "6\n \n\n* * *"}, {"input": "100 100 100", "output": "0"}] |
Print the minimum total cost required to complete all the task.
* * * | s119664018 | Wrong Answer | p03292 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | s_i = [int(s_v) for s_v in input().split()]
sum_cost = abs(s_i[1] - s_i[2])
a = abs(s_i[0] - s_i[1])
b = abs(s_i[0] - s_i[2])
if a >= b:
sum_cost += b
else:
sum_cost += a
print(sum_cost)
| Statement
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 0.
Then, just after completing the i-th task, you can complete the j-th task at
cost |A_j - A_i|.
Here, |x| denotes the absolute value of x.
Find the minimum total cost required to complete all the task. | [{"input": "1 6 3", "output": "5\n \n\nWhen the tasks are completed in the following order, the total cost will be 5,\nwhich is the minimum:\n\n * Complete the first task at cost 0.\n * Complete the third task at cost 2.\n * Complete the second task at cost 3.\n\n* * *"}, {"input": "11 5 5", "output": "6\n \n\n* * *"}, {"input": "100 100 100", "output": "0"}] |
Print the minimum total cost required to complete all the task.
* * * | s317568887 | Runtime Error | p03292 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | import itertools
A1,A2,A3 = map(int,input().split())
vec = [A1,A2,A3]
com = list(itertools.permutations(vec))
all_cos = [0,0,0,0,0,0]
for i in range(6):
tmp_com = com[i]
tmp_A1 = tmp_com[0]
tmp_A2 = tmp_com[1]
tmp_A3 = tmp_com[2]
cos1 = 0
cos2 = abs(tmp_A1 - tmp_A2)
cos3 = abs(tmp_A2 - tmp_A3)
all_cos[i] = cos1 + cos2 + cos3
res = min(all_cos)
print(res)
| Statement
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 0.
Then, just after completing the i-th task, you can complete the j-th task at
cost |A_j - A_i|.
Here, |x| denotes the absolute value of x.
Find the minimum total cost required to complete all the task. | [{"input": "1 6 3", "output": "5\n \n\nWhen the tasks are completed in the following order, the total cost will be 5,\nwhich is the minimum:\n\n * Complete the first task at cost 0.\n * Complete the third task at cost 2.\n * Complete the second task at cost 3.\n\n* * *"}, {"input": "11 5 5", "output": "6\n \n\n* * *"}, {"input": "100 100 100", "output": "0"}] |
Print the minimum total cost required to complete all the task.
* * * | s712652313 | Runtime Error | p03292 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | A1, A2, A3 = map(int, input().split())
print(min(abs(A1 - A2) + abs(A2 - A3), abs(A1 - A3) + abs(A2 - A3), abs(A2 - A1) + abs(A1 - A3), abs(A2 - A3) + abs(A3 - A1), abs(A3 - A1) + abs(A1 - A2), abs(A3 - A2) + abs(A2 - A1)) | Statement
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 0.
Then, just after completing the i-th task, you can complete the j-th task at
cost |A_j - A_i|.
Here, |x| denotes the absolute value of x.
Find the minimum total cost required to complete all the task. | [{"input": "1 6 3", "output": "5\n \n\nWhen the tasks are completed in the following order, the total cost will be 5,\nwhich is the minimum:\n\n * Complete the first task at cost 0.\n * Complete the third task at cost 2.\n * Complete the second task at cost 3.\n\n* * *"}, {"input": "11 5 5", "output": "6\n \n\n* * *"}, {"input": "100 100 100", "output": "0"}] |
Print the minimum total cost required to complete all the task.
* * * | s531425442 | Wrong Answer | p03292 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | a, b, c = input().split()
x, y, z = (int(a), int(b), int(c))
sample_list = [x, y, z]
abs_list = [abs(x - y), abs(x - z)]
abs_max = max(abs_list)
abs_min = min(abs_list)
if x == max(sample_list) or x == min(sample_list):
print(abs_max)
else:
print(abs_min * 2 + abs_max)
| Statement
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 0.
Then, just after completing the i-th task, you can complete the j-th task at
cost |A_j - A_i|.
Here, |x| denotes the absolute value of x.
Find the minimum total cost required to complete all the task. | [{"input": "1 6 3", "output": "5\n \n\nWhen the tasks are completed in the following order, the total cost will be 5,\nwhich is the minimum:\n\n * Complete the first task at cost 0.\n * Complete the third task at cost 2.\n * Complete the second task at cost 3.\n\n* * *"}, {"input": "11 5 5", "output": "6\n \n\n* * *"}, {"input": "100 100 100", "output": "0"}] |
Print the minimum total cost required to complete all the task.
* * * | s961811145 | Accepted | p03292 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | p, q, r = map(int, input().split())
print(min([abs(p - q) + abs(q - r), abs(q - r) + abs(p - r), abs(p - q) + abs(p - r)]))
| Statement
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 0.
Then, just after completing the i-th task, you can complete the j-th task at
cost |A_j - A_i|.
Here, |x| denotes the absolute value of x.
Find the minimum total cost required to complete all the task. | [{"input": "1 6 3", "output": "5\n \n\nWhen the tasks are completed in the following order, the total cost will be 5,\nwhich is the minimum:\n\n * Complete the first task at cost 0.\n * Complete the third task at cost 2.\n * Complete the second task at cost 3.\n\n* * *"}, {"input": "11 5 5", "output": "6\n \n\n* * *"}, {"input": "100 100 100", "output": "0"}] |
Print the minimum total cost required to complete all the task.
* * * | s826518155 | Accepted | p03292 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | A1, A2, A3 = [int(i) for i in sorted(input().split())]
print(A3 - A1) if A3 - A1 > 0 else print(A1 - A3)
| Statement
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 0.
Then, just after completing the i-th task, you can complete the j-th task at
cost |A_j - A_i|.
Here, |x| denotes the absolute value of x.
Find the minimum total cost required to complete all the task. | [{"input": "1 6 3", "output": "5\n \n\nWhen the tasks are completed in the following order, the total cost will be 5,\nwhich is the minimum:\n\n * Complete the first task at cost 0.\n * Complete the third task at cost 2.\n * Complete the second task at cost 3.\n\n* * *"}, {"input": "11 5 5", "output": "6\n \n\n* * *"}, {"input": "100 100 100", "output": "0"}] |
Print the minimum total cost required to complete all the task.
* * * | s844730939 | Accepted | p03292 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | a, b, c = map(int, input().split(" "))
l = list(map(abs, [a - b, a - c, b - c]))
print(sum(l) - max(l))
| Statement
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 0.
Then, just after completing the i-th task, you can complete the j-th task at
cost |A_j - A_i|.
Here, |x| denotes the absolute value of x.
Find the minimum total cost required to complete all the task. | [{"input": "1 6 3", "output": "5\n \n\nWhen the tasks are completed in the following order, the total cost will be 5,\nwhich is the minimum:\n\n * Complete the first task at cost 0.\n * Complete the third task at cost 2.\n * Complete the second task at cost 3.\n\n* * *"}, {"input": "11 5 5", "output": "6\n \n\n* * *"}, {"input": "100 100 100", "output": "0"}] |
Print the minimum total cost required to complete all the task.
* * * | s681119366 | Accepted | p03292 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | one, two, three = map(int, input().split())
ma = max([one, two, three])
mi = min([one, two, three])
print(ma - mi)
| Statement
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 0.
Then, just after completing the i-th task, you can complete the j-th task at
cost |A_j - A_i|.
Here, |x| denotes the absolute value of x.
Find the minimum total cost required to complete all the task. | [{"input": "1 6 3", "output": "5\n \n\nWhen the tasks are completed in the following order, the total cost will be 5,\nwhich is the minimum:\n\n * Complete the first task at cost 0.\n * Complete the third task at cost 2.\n * Complete the second task at cost 3.\n\n* * *"}, {"input": "11 5 5", "output": "6\n \n\n* * *"}, {"input": "100 100 100", "output": "0"}] |
Print the minimum total cost required to complete all the task.
* * * | s589736246 | Runtime Error | p03292 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | A = list(map(int, input().split()))
l = [[0,1],[1,2],[0,3]
ll
for i,j in l:
ll.append(abs(A[i]-A[j]))
print(min(ll)) | Statement
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 0.
Then, just after completing the i-th task, you can complete the j-th task at
cost |A_j - A_i|.
Here, |x| denotes the absolute value of x.
Find the minimum total cost required to complete all the task. | [{"input": "1 6 3", "output": "5\n \n\nWhen the tasks are completed in the following order, the total cost will be 5,\nwhich is the minimum:\n\n * Complete the first task at cost 0.\n * Complete the third task at cost 2.\n * Complete the second task at cost 3.\n\n* * *"}, {"input": "11 5 5", "output": "6\n \n\n* * *"}, {"input": "100 100 100", "output": "0"}] |
Print the minimum total cost required to complete all the task.
* * * | s125377912 | Runtime Error | p03292 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | list N =[]
N = int(input().split())
N1 = []
N1 = sort(N)
int ans = 0
ans+=N1[1]-N1[0]
ans+=N1[2]-N1[1]
print(ans) | Statement
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 0.
Then, just after completing the i-th task, you can complete the j-th task at
cost |A_j - A_i|.
Here, |x| denotes the absolute value of x.
Find the minimum total cost required to complete all the task. | [{"input": "1 6 3", "output": "5\n \n\nWhen the tasks are completed in the following order, the total cost will be 5,\nwhich is the minimum:\n\n * Complete the first task at cost 0.\n * Complete the third task at cost 2.\n * Complete the second task at cost 3.\n\n* * *"}, {"input": "11 5 5", "output": "6\n \n\n* * *"}, {"input": "100 100 100", "output": "0"}] |
Print the minimum total cost required to complete all the task.
* * * | s772178766 | Runtime Error | p03292 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | s1 = input()
print("Yes" if input() in tuple(s1[i:] + s1[:i] for i in range(len(s1))) else "No")
| Statement
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 0.
Then, just after completing the i-th task, you can complete the j-th task at
cost |A_j - A_i|.
Here, |x| denotes the absolute value of x.
Find the minimum total cost required to complete all the task. | [{"input": "1 6 3", "output": "5\n \n\nWhen the tasks are completed in the following order, the total cost will be 5,\nwhich is the minimum:\n\n * Complete the first task at cost 0.\n * Complete the third task at cost 2.\n * Complete the second task at cost 3.\n\n* * *"}, {"input": "11 5 5", "output": "6\n \n\n* * *"}, {"input": "100 100 100", "output": "0"}] |
Print the minimum total cost required to complete all the task.
* * * | s488300185 | Runtime Error | p03292 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | a = list(map(int, input().split()))
print(min(abs(a[0]-a[1])+abs(a[1]-a[2]), abs(a[0]-a[2])+abs(a[1]-a[0])), abs(a[0]-a[2])+abs(a[1]-a[2])))
| Statement
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 0.
Then, just after completing the i-th task, you can complete the j-th task at
cost |A_j - A_i|.
Here, |x| denotes the absolute value of x.
Find the minimum total cost required to complete all the task. | [{"input": "1 6 3", "output": "5\n \n\nWhen the tasks are completed in the following order, the total cost will be 5,\nwhich is the minimum:\n\n * Complete the first task at cost 0.\n * Complete the third task at cost 2.\n * Complete the second task at cost 3.\n\n* * *"}, {"input": "11 5 5", "output": "6\n \n\n* * *"}, {"input": "100 100 100", "output": "0"}] |
Print the minimum total cost required to complete all the task.
* * * | s839869678 | Runtime Error | p03292 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | A=list(map(int,input().split()))
A.sort()
for i in range(len(A)):
if i=0:
continue
else:
res=A[i]-A[i-1]
print(res)
| Statement
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 0.
Then, just after completing the i-th task, you can complete the j-th task at
cost |A_j - A_i|.
Here, |x| denotes the absolute value of x.
Find the minimum total cost required to complete all the task. | [{"input": "1 6 3", "output": "5\n \n\nWhen the tasks are completed in the following order, the total cost will be 5,\nwhich is the minimum:\n\n * Complete the first task at cost 0.\n * Complete the third task at cost 2.\n * Complete the second task at cost 3.\n\n* * *"}, {"input": "11 5 5", "output": "6\n \n\n* * *"}, {"input": "100 100 100", "output": "0"}] |
Print the minimum total cost required to complete all the task.
* * * | s254142818 | Accepted | p03292 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | numbers = list(map(int, input().split()))
print(max(numbers) - min(numbers))
| Statement
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 0.
Then, just after completing the i-th task, you can complete the j-th task at
cost |A_j - A_i|.
Here, |x| denotes the absolute value of x.
Find the minimum total cost required to complete all the task. | [{"input": "1 6 3", "output": "5\n \n\nWhen the tasks are completed in the following order, the total cost will be 5,\nwhich is the minimum:\n\n * Complete the first task at cost 0.\n * Complete the third task at cost 2.\n * Complete the second task at cost 3.\n\n* * *"}, {"input": "11 5 5", "output": "6\n \n\n* * *"}, {"input": "100 100 100", "output": "0"}] |
Print the minimum total cost required to complete all the task.
* * * | s771880996 | Accepted | p03292 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | Ai = list(map(int, input().split()))
Ai.sort()
print(Ai[2] - Ai[0])
| Statement
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 0.
Then, just after completing the i-th task, you can complete the j-th task at
cost |A_j - A_i|.
Here, |x| denotes the absolute value of x.
Find the minimum total cost required to complete all the task. | [{"input": "1 6 3", "output": "5\n \n\nWhen the tasks are completed in the following order, the total cost will be 5,\nwhich is the minimum:\n\n * Complete the first task at cost 0.\n * Complete the third task at cost 2.\n * Complete the second task at cost 3.\n\n* * *"}, {"input": "11 5 5", "output": "6\n \n\n* * *"}, {"input": "100 100 100", "output": "0"}] |
Print the minimum total cost required to complete all the task.
* * * | s426663291 | Accepted | p03292 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | a_list = sorted(map(int, input().split()))
print(a_list[2] - a_list[0])
| Statement
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 0.
Then, just after completing the i-th task, you can complete the j-th task at
cost |A_j - A_i|.
Here, |x| denotes the absolute value of x.
Find the minimum total cost required to complete all the task. | [{"input": "1 6 3", "output": "5\n \n\nWhen the tasks are completed in the following order, the total cost will be 5,\nwhich is the minimum:\n\n * Complete the first task at cost 0.\n * Complete the third task at cost 2.\n * Complete the second task at cost 3.\n\n* * *"}, {"input": "11 5 5", "output": "6\n \n\n* * *"}, {"input": "100 100 100", "output": "0"}] |
Print the minimum total cost required to complete all the task.
* * * | s203342449 | Accepted | p03292 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | AAA = sorted(list(map(int, input().split())))
print(AAA[2] - AAA[0])
| Statement
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 0.
Then, just after completing the i-th task, you can complete the j-th task at
cost |A_j - A_i|.
Here, |x| denotes the absolute value of x.
Find the minimum total cost required to complete all the task. | [{"input": "1 6 3", "output": "5\n \n\nWhen the tasks are completed in the following order, the total cost will be 5,\nwhich is the minimum:\n\n * Complete the first task at cost 0.\n * Complete the third task at cost 2.\n * Complete the second task at cost 3.\n\n* * *"}, {"input": "11 5 5", "output": "6\n \n\n* * *"}, {"input": "100 100 100", "output": "0"}] |
Print the minimum total cost required to complete all the task.
* * * | s194471141 | Accepted | p03292 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | L = sorted(map(int, input().split()), reverse=True)
print((L[0] - L[1]) + (L[1] - L[2]))
| Statement
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 0.
Then, just after completing the i-th task, you can complete the j-th task at
cost |A_j - A_i|.
Here, |x| denotes the absolute value of x.
Find the minimum total cost required to complete all the task. | [{"input": "1 6 3", "output": "5\n \n\nWhen the tasks are completed in the following order, the total cost will be 5,\nwhich is the minimum:\n\n * Complete the first task at cost 0.\n * Complete the third task at cost 2.\n * Complete the second task at cost 3.\n\n* * *"}, {"input": "11 5 5", "output": "6\n \n\n* * *"}, {"input": "100 100 100", "output": "0"}] |
Print the minimum total cost required to complete all the task.
* * * | s190200924 | Runtime Error | p03292 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | 1, A2, A3 = map(int, input().split())
print(max(A1, A2, A3) - min(A1, A2, A3))
| Statement
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 0.
Then, just after completing the i-th task, you can complete the j-th task at
cost |A_j - A_i|.
Here, |x| denotes the absolute value of x.
Find the minimum total cost required to complete all the task. | [{"input": "1 6 3", "output": "5\n \n\nWhen the tasks are completed in the following order, the total cost will be 5,\nwhich is the minimum:\n\n * Complete the first task at cost 0.\n * Complete the third task at cost 2.\n * Complete the second task at cost 3.\n\n* * *"}, {"input": "11 5 5", "output": "6\n \n\n* * *"}, {"input": "100 100 100", "output": "0"}] |
Print the minimum total cost required to complete all the task.
* * * | s652515827 | Runtime Error | p03292 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | # A - Task Scheduling Problem
*a=map(int,input().split())
print(max(a)- min(a) | Statement
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 0.
Then, just after completing the i-th task, you can complete the j-th task at
cost |A_j - A_i|.
Here, |x| denotes the absolute value of x.
Find the minimum total cost required to complete all the task. | [{"input": "1 6 3", "output": "5\n \n\nWhen the tasks are completed in the following order, the total cost will be 5,\nwhich is the minimum:\n\n * Complete the first task at cost 0.\n * Complete the third task at cost 2.\n * Complete the second task at cost 3.\n\n* * *"}, {"input": "11 5 5", "output": "6\n \n\n* * *"}, {"input": "100 100 100", "output": "0"}] |
Print the minimum total cost required to complete all the task.
* * * | s735206002 | Wrong Answer | p03292 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | L = sorted(map(int, input().split()))
ans = max(L) - min(L)
print("ans")
| Statement
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 0.
Then, just after completing the i-th task, you can complete the j-th task at
cost |A_j - A_i|.
Here, |x| denotes the absolute value of x.
Find the minimum total cost required to complete all the task. | [{"input": "1 6 3", "output": "5\n \n\nWhen the tasks are completed in the following order, the total cost will be 5,\nwhich is the minimum:\n\n * Complete the first task at cost 0.\n * Complete the third task at cost 2.\n * Complete the second task at cost 3.\n\n* * *"}, {"input": "11 5 5", "output": "6\n \n\n* * *"}, {"input": "100 100 100", "output": "0"}] |
Print the minimum total cost required to complete all the task.
* * * | s790977735 | Runtime Error | p03292 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | A = list(map(int, input().split())
A.sort()
print(-A[0] + A[2]) | Statement
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 0.
Then, just after completing the i-th task, you can complete the j-th task at
cost |A_j - A_i|.
Here, |x| denotes the absolute value of x.
Find the minimum total cost required to complete all the task. | [{"input": "1 6 3", "output": "5\n \n\nWhen the tasks are completed in the following order, the total cost will be 5,\nwhich is the minimum:\n\n * Complete the first task at cost 0.\n * Complete the third task at cost 2.\n * Complete the second task at cost 3.\n\n* * *"}, {"input": "11 5 5", "output": "6\n \n\n* * *"}, {"input": "100 100 100", "output": "0"}] |
Print the minimum total cost required to complete all the task.
* * * | s814166528 | Runtime Error | p03292 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | data = lists(map(int, input().split()))
print(max(data) - min(data))
| Statement
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 0.
Then, just after completing the i-th task, you can complete the j-th task at
cost |A_j - A_i|.
Here, |x| denotes the absolute value of x.
Find the minimum total cost required to complete all the task. | [{"input": "1 6 3", "output": "5\n \n\nWhen the tasks are completed in the following order, the total cost will be 5,\nwhich is the minimum:\n\n * Complete the first task at cost 0.\n * Complete the third task at cost 2.\n * Complete the second task at cost 3.\n\n* * *"}, {"input": "11 5 5", "output": "6\n \n\n* * *"}, {"input": "100 100 100", "output": "0"}] |
Print the minimum total cost required to complete all the task.
* * * | s876478414 | Runtime Error | p03292 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | p = list(map(int, input().split(" ")))
p = sorted(a)
print(p[2] - p[0])
| Statement
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 0.
Then, just after completing the i-th task, you can complete the j-th task at
cost |A_j - A_i|.
Here, |x| denotes the absolute value of x.
Find the minimum total cost required to complete all the task. | [{"input": "1 6 3", "output": "5\n \n\nWhen the tasks are completed in the following order, the total cost will be 5,\nwhich is the minimum:\n\n * Complete the first task at cost 0.\n * Complete the third task at cost 2.\n * Complete the second task at cost 3.\n\n* * *"}, {"input": "11 5 5", "output": "6\n \n\n* * *"}, {"input": "100 100 100", "output": "0"}] |
Print the minimum total cost required to complete all the task.
* * * | s607347347 | Runtime Error | p03292 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | k = list(map(int, input().split()))
print(abs(max(k) - max(k)[1]) + abs(max(k)[1] - max(k)[2]))
| Statement
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 0.
Then, just after completing the i-th task, you can complete the j-th task at
cost |A_j - A_i|.
Here, |x| denotes the absolute value of x.
Find the minimum total cost required to complete all the task. | [{"input": "1 6 3", "output": "5\n \n\nWhen the tasks are completed in the following order, the total cost will be 5,\nwhich is the minimum:\n\n * Complete the first task at cost 0.\n * Complete the third task at cost 2.\n * Complete the second task at cost 3.\n\n* * *"}, {"input": "11 5 5", "output": "6\n \n\n* * *"}, {"input": "100 100 100", "output": "0"}] |
Print the minimum total cost required to complete all the task.
* * * | s118909492 | Runtime Error | p03292 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | tasks = sorted([int(v) for v in input.split()])
print(tasks[-1] - tasks[0])
| Statement
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 0.
Then, just after completing the i-th task, you can complete the j-th task at
cost |A_j - A_i|.
Here, |x| denotes the absolute value of x.
Find the minimum total cost required to complete all the task. | [{"input": "1 6 3", "output": "5\n \n\nWhen the tasks are completed in the following order, the total cost will be 5,\nwhich is the minimum:\n\n * Complete the first task at cost 0.\n * Complete the third task at cost 2.\n * Complete the second task at cost 3.\n\n* * *"}, {"input": "11 5 5", "output": "6\n \n\n* * *"}, {"input": "100 100 100", "output": "0"}] |
Print the minimum total cost required to complete all the task.
* * * | s870843244 | Runtime Error | p03292 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | s=list(map(int,input().split())
s.sort()
print(s[2]-s[0])
| Statement
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 0.
Then, just after completing the i-th task, you can complete the j-th task at
cost |A_j - A_i|.
Here, |x| denotes the absolute value of x.
Find the minimum total cost required to complete all the task. | [{"input": "1 6 3", "output": "5\n \n\nWhen the tasks are completed in the following order, the total cost will be 5,\nwhich is the minimum:\n\n * Complete the first task at cost 0.\n * Complete the third task at cost 2.\n * Complete the second task at cost 3.\n\n* * *"}, {"input": "11 5 5", "output": "6\n \n\n* * *"}, {"input": "100 100 100", "output": "0"}] |
Print the minimum total cost required to complete all the task.
* * * | s930514274 | Accepted | p03292 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | #!/usr/bin/env python3
import sys
# import math
# from string import ascii_lowercase, ascii_upper_case, 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 operator import itemgetter # itemgetter(1), itemgetter('key')
# 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 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 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 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 copy import deepcopy # to copy multi-dimentional matrix without reference
# 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()
L = [a, b, c]
L.sort()
print(L[-1] - L[0])
if __name__ == "__main__":
main()
| Statement
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 0.
Then, just after completing the i-th task, you can complete the j-th task at
cost |A_j - A_i|.
Here, |x| denotes the absolute value of x.
Find the minimum total cost required to complete all the task. | [{"input": "1 6 3", "output": "5\n \n\nWhen the tasks are completed in the following order, the total cost will be 5,\nwhich is the minimum:\n\n * Complete the first task at cost 0.\n * Complete the third task at cost 2.\n * Complete the second task at cost 3.\n\n* * *"}, {"input": "11 5 5", "output": "6\n \n\n* * *"}, {"input": "100 100 100", "output": "0"}] |
Print the minimum total cost required to complete all the task.
* * * | s549663828 | Accepted | p03292 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | a = [int(x) for x in input().split()]
min_val = float("inf")
for i in range(len(a)):
val = 0
b = a[0:i] + a[i + 1 : len(a)]
if abs(a[i] - b[0]) < abs(a[i] - b[1]):
val += abs(a[i] - b[0])
val += abs(b[0] - b[1])
else:
val += abs(a[i] - b[1])
val += abs(b[1] - b[0])
min_val = min(min_val, val)
print(min_val)
| Statement
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 0.
Then, just after completing the i-th task, you can complete the j-th task at
cost |A_j - A_i|.
Here, |x| denotes the absolute value of x.
Find the minimum total cost required to complete all the task. | [{"input": "1 6 3", "output": "5\n \n\nWhen the tasks are completed in the following order, the total cost will be 5,\nwhich is the minimum:\n\n * Complete the first task at cost 0.\n * Complete the third task at cost 2.\n * Complete the second task at cost 3.\n\n* * *"}, {"input": "11 5 5", "output": "6\n \n\n* * *"}, {"input": "100 100 100", "output": "0"}] |
Print the minimum total cost required to complete all the task.
* * * | s726533364 | Accepted | p03292 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | A = list(map(int, input().split()))
def abs_A(A1, A2, A3):
return abs(A1 - A2) + abs(A2 - A3)
minA = min(
abs_A(A[0], A[1], A[2]),
abs_A(A[0], A[2], A[1]),
abs_A(A[1], A[0], A[2]),
abs_A(A[1], A[2], A[0]),
abs_A(A[2], A[0], A[1]),
abs_A(A[2], A[1], A[0]),
)
print(minA)
| Statement
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 0.
Then, just after completing the i-th task, you can complete the j-th task at
cost |A_j - A_i|.
Here, |x| denotes the absolute value of x.
Find the minimum total cost required to complete all the task. | [{"input": "1 6 3", "output": "5\n \n\nWhen the tasks are completed in the following order, the total cost will be 5,\nwhich is the minimum:\n\n * Complete the first task at cost 0.\n * Complete the third task at cost 2.\n * Complete the second task at cost 3.\n\n* * *"}, {"input": "11 5 5", "output": "6\n \n\n* * *"}, {"input": "100 100 100", "output": "0"}] |
Print the minimum total cost required to complete all the task.
* * * | s182096292 | Accepted | p03292 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | import math
li = list(map(int, input().split()))
cost = 10000
c = abs(li[0] - li[1]) + abs(li[2] - li[1])
if c < cost:
cost = c
c = abs(li[0] - li[2]) + abs(li[2] - li[1])
if c < cost:
cost = c
c = abs(li[0] - li[1]) + abs(li[2] - li[0])
if c < cost:
cost = c
c = abs(li[2] - li[1]) + abs(li[2] - li[0])
if c < cost:
cost = c
c = abs(li[2] - li[0]) + abs(li[0] - li[1])
if c < cost:
cost = c
c = abs(li[2] - li[1]) + abs(li[0] - li[1])
if c < cost:
cost = c
print(cost)
| Statement
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 0.
Then, just after completing the i-th task, you can complete the j-th task at
cost |A_j - A_i|.
Here, |x| denotes the absolute value of x.
Find the minimum total cost required to complete all the task. | [{"input": "1 6 3", "output": "5\n \n\nWhen the tasks are completed in the following order, the total cost will be 5,\nwhich is the minimum:\n\n * Complete the first task at cost 0.\n * Complete the third task at cost 2.\n * Complete the second task at cost 3.\n\n* * *"}, {"input": "11 5 5", "output": "6\n \n\n* * *"}, {"input": "100 100 100", "output": "0"}] |
Print the minimum total cost required to complete all the task.
* * * | s736803979 | Accepted | p03292 | Input is given from Standard Input in the following format:
A_1 A_2 A_3 | a = list(map(int, input().split()))
ls = []
ls.append(abs(a[0] - a[1]))
ls.append(abs(a[1] - a[2]))
ls.append(abs(a[0] - a[2]))
ls = sorted(ls)
print(ls[0] + ls[1])
| Statement
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 0.
Then, just after completing the i-th task, you can complete the j-th task at
cost |A_j - A_i|.
Here, |x| denotes the absolute value of x.
Find the minimum total cost required to complete all the task. | [{"input": "1 6 3", "output": "5\n \n\nWhen the tasks are completed in the following order, the total cost will be 5,\nwhich is the minimum:\n\n * Complete the first task at cost 0.\n * Complete the third task at cost 2.\n * Complete the second task at cost 3.\n\n* * *"}, {"input": "11 5 5", "output": "6\n \n\n* * *"}, {"input": "100 100 100", "output": "0"}] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.