結果

問題 No.472 平均順位
ユーザー bashiriskbashirisk
提出日時 2017-03-12 21:11:44
言語 Python2
(2.7.18)
結果
TLE  
実行時間 -
コード長 795 bytes
コンパイル時間 100 ms
コンパイル使用メモリ 6,612 KB
実行使用メモリ 10,468 KB
最終ジャッジ日時 2023-09-12 12:10:20
合計ジャッジ時間 3,841 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
10,468 KB
testcase_01 AC 11 ms
5,956 KB
testcase_02 AC 11 ms
5,948 KB
testcase_03 AC 11 ms
5,956 KB
testcase_04 TLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

def rank(a,b,c,p):
  if p==0:
    return a
  elif p==1:
    return b
  elif p ==2:
    return c
  else:
    return 1

def sumrank(a,b,c,N,P):
  if N == 1:
    return rank(a[0],b[0],c[0],P)
  else:
    maxlastp = min(P,3)
    minlastp = max(0,P - 3*(N-1))
    result = []
    for lastp in range(minlastp,maxlastp +1):
      result.append(sumrank(a[0:N-1],b[0:N-1],c[0:N-1],N-1,P-lastp) + rank(a[N-1],b[N-1],c[N-1],lastp))
    return min(result)

def averagerank(a,b,c,N,P):
  return float(sumrank(a,b,c,N,P))/float(N)

input = raw_input()
N=int(input.split(' ')[0])
P =int(input.split(' ')[1])
a = []
b = []
c = []
for i in range(N):
  input = raw_input()
  a.append(int(input.split(' ')[0]))
  b.append(int(input.split(' ')[1]))
  c.append(int(input.split(' ')[2]))
print averagerank(a,b,c,N,P)
0