結果
問題 | No.9 モンスターのレベル上げ |
ユーザー | 6soukiti29 |
提出日時 | 2017-07-20 20:26:25 |
言語 | Nim (2.0.2) |
結果 |
AC
|
実行時間 | 769 ms / 5,000 ms |
コード長 | 1,992 bytes |
コンパイル時間 | 3,615 ms |
コンパイル使用メモリ | 68,596 KB |
実行使用メモリ | 4,380 KB |
最終ジャッジ日時 | 2023-09-12 13:28:47 |
合計ジャッジ時間 | 11,173 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge11 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,376 KB |
testcase_01 | AC | 2 ms
4,376 KB |
testcase_02 | AC | 769 ms
4,376 KB |
testcase_03 | AC | 590 ms
4,376 KB |
testcase_04 | AC | 315 ms
4,380 KB |
testcase_05 | AC | 207 ms
4,376 KB |
testcase_06 | AC | 70 ms
4,376 KB |
testcase_07 | AC | 2 ms
4,380 KB |
testcase_08 | AC | 95 ms
4,380 KB |
testcase_09 | AC | 740 ms
4,376 KB |
testcase_10 | AC | 2 ms
4,376 KB |
testcase_11 | AC | 692 ms
4,380 KB |
testcase_12 | AC | 665 ms
4,376 KB |
testcase_13 | AC | 333 ms
4,380 KB |
testcase_14 | AC | 741 ms
4,380 KB |
testcase_15 | AC | 677 ms
4,376 KB |
testcase_16 | AC | 12 ms
4,380 KB |
testcase_17 | AC | 432 ms
4,380 KB |
testcase_18 | AC | 363 ms
4,376 KB |
testcase_19 | AC | 7 ms
4,380 KB |
コンパイルメッセージ
/home/judge/data/code/Main.nim(21, 25) Warning: Number of spaces around '<=' is not consistent [Spacing] /home/judge/data/code/Main.nim(1, 26) Warning: imported and not used: 'math' [UnusedImport]
ソースコード
import sequtils,strutils,math type priorityQue[I:static[int];T:tuple] = array[I + 1,T] item = tuple[cost: int,ID : int] proc push[T](A:var priorityQue; b: T;)= const key = 0 A[0][0] += 1 A[A[0][0]] = b # A[0][0]はsize、最大のIndex var index = A[0][0] while index > 1 and A[index][key] > A[index div 2][key]: (A[index],A[index div 2]) = (A[index div 2],A[index]) index = index div 2 proc pop(A: var priorityQue):item = #戻り値を書き換える const key = 0 result = A[1] A[1] = A[A[0][0]] A[A[0][0]] = (0,0) A[0][0] -= 1 var index = 1 while index * 2 <= A[0][0]: if index * 2 + 1<= A[0][0]: if A[index][key] < A[index * 2][key] and A[index * 2 + 1][key] <= A[index * 2][key]: (A[index],A[index * 2]) = (A[index * 2],A[index]) index = index * 2 elif A[index][key] < A[index * 2 + 1][key]: (A[index],A[index * 2 + 1]) = (A[index * 2 + 1],A[index]) index = index * 2 + 1 else: break elif index * 2 <= A[0][0]: if A[index][key] < A[index * 2][key]: (A[index],A[index * 2]) = (A[index * 2],A[index]) break else: break proc size(A : priorityQue):int= return A[0][0] var N = stdin.readline.parseInt A = stdin.readline.split.map(parseInt) B = stdin.readline.split.map(parseInt) pQueA : priorityQue[1500,item] p : int ans,cnt : int monster : item for n in 0..<N: pQueA.push((- A[n] * 10000 ,n)) ans = high(int) for n in 0..<N: var pQueB = pQueA for i in 0..<N: p = (n + i) mod N monster = pQueB.pop monster.cost -= 1 monster.cost -= B[p] div 2 * 10000 pQueB.push(monster) cnt = 0 while pQueB.size > 0: monster = pQueB.pop cnt = max(cnt, (-1 * monster.cost) mod 10000) ans = min(ans,cnt) echo ans