結果
問題 |
No.472 平均順位
|
ユーザー |
![]() |
提出日時 | 2017-03-12 21:11:44 |
言語 | Python2 (2.7.18) |
結果 |
TLE
|
実行時間 | - |
コード長 | 795 bytes |
コンパイル時間 | 402 ms |
コンパイル使用メモリ | 6,912 KB |
実行使用メモリ | 13,340 KB |
最終ジャッジ日時 | 2024-06-30 00:35:41 |
合計ジャッジ時間 | 3,847 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | TLE * 1 -- * 15 |
ソースコード
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)