結果
問題 | No.2856 Junk Market Game |
ユーザー | kemuniku |
提出日時 | 2024-08-25 16:34:05 |
言語 | Nim (2.0.2) |
結果 |
AC
|
実行時間 | 74 ms / 2,000 ms |
コード長 | 3,932 bytes |
コンパイル時間 | 3,984 ms |
コンパイル使用メモリ | 77,908 KB |
実行使用メモリ | 36,880 KB |
最終ジャッジ日時 | 2024-08-25 16:34:14 |
合計ジャッジ時間 | 7,333 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,812 KB |
testcase_01 | AC | 1 ms
6,940 KB |
testcase_02 | AC | 1 ms
6,940 KB |
testcase_03 | AC | 2 ms
6,940 KB |
testcase_04 | AC | 1 ms
6,944 KB |
testcase_05 | AC | 1 ms
6,944 KB |
testcase_06 | AC | 1 ms
6,944 KB |
testcase_07 | AC | 1 ms
6,940 KB |
testcase_08 | AC | 1 ms
6,944 KB |
testcase_09 | AC | 1 ms
6,944 KB |
testcase_10 | AC | 22 ms
15,272 KB |
testcase_11 | AC | 56 ms
31,904 KB |
testcase_12 | AC | 72 ms
34,948 KB |
testcase_13 | AC | 17 ms
10,240 KB |
testcase_14 | AC | 52 ms
30,808 KB |
testcase_15 | AC | 23 ms
15,360 KB |
testcase_16 | AC | 58 ms
33,360 KB |
testcase_17 | AC | 31 ms
19,540 KB |
testcase_18 | AC | 36 ms
20,292 KB |
testcase_19 | AC | 28 ms
18,432 KB |
testcase_20 | AC | 17 ms
10,880 KB |
testcase_21 | AC | 58 ms
34,176 KB |
testcase_22 | AC | 56 ms
32,164 KB |
testcase_23 | AC | 37 ms
20,468 KB |
testcase_24 | AC | 38 ms
21,004 KB |
testcase_25 | AC | 16 ms
9,984 KB |
testcase_26 | AC | 1 ms
6,940 KB |
testcase_27 | AC | 50 ms
29,980 KB |
testcase_28 | AC | 26 ms
16,728 KB |
testcase_29 | AC | 59 ms
34,192 KB |
testcase_30 | AC | 69 ms
35,428 KB |
testcase_31 | AC | 67 ms
36,700 KB |
testcase_32 | AC | 66 ms
35,428 KB |
testcase_33 | AC | 73 ms
36,324 KB |
testcase_34 | AC | 67 ms
36,132 KB |
testcase_35 | AC | 65 ms
36,724 KB |
testcase_36 | AC | 65 ms
35,560 KB |
testcase_37 | AC | 66 ms
35,584 KB |
testcase_38 | AC | 65 ms
36,880 KB |
testcase_39 | AC | 66 ms
36,672 KB |
testcase_40 | AC | 66 ms
36,524 KB |
testcase_41 | AC | 66 ms
35,756 KB |
testcase_42 | AC | 67 ms
35,488 KB |
testcase_43 | AC | 66 ms
35,816 KB |
testcase_44 | AC | 63 ms
35,536 KB |
testcase_45 | AC | 64 ms
36,844 KB |
testcase_46 | AC | 66 ms
35,444 KB |
testcase_47 | AC | 66 ms
35,356 KB |
testcase_48 | AC | 65 ms
36,088 KB |
testcase_49 | AC | 74 ms
35,512 KB |
testcase_50 | AC | 63 ms
35,676 KB |
testcase_51 | AC | 65 ms
36,040 KB |
ソースコード
import macros;macro ImportExpand(s:untyped):untyped = parseStmt($s[2]) ImportExpand "cplib/tmpl/sheep.nim" <=== "when not declared CPLIB_TMPL_SHEEP:\n const CPLIB_TMPL_SHEEP* = 1\n {.warning[UnusedImport]: off.}\n {.hint[XDeclaredButNotUsed]: off.}\n import algorithm\n import sequtils\n import tables\n import macros\n import math\n import sets\n import strutils\n import strformat\n import sugar\n import heapqueue\n import streams\n import deques\n import bitops\n import std/lenientops\n import options\n #入力系\n proc scanf(formatstr: cstring){.header: \"<stdio.h>\", varargs.}\n proc getchar(): char {.importc: \"getchar_unlocked\", header: \"<stdio.h>\", discardable.}\n proc ii(): int {.inline.} = scanf(\"%lld\\n\", addr result)\n proc lii(N: int): seq[int] {.inline.} = newSeqWith(N, ii())\n proc si(): string {.inline.} =\n result = \"\"\n var c: char\n while true:\n c = getchar()\n if c == ' ' or c == '\\n':\n break\n result &= c\n #chmin,chmax\n template `max=`(x, y) = x = max(x, y)\n template `min=`(x, y) = x = min(x, y)\n #bit演算\n proc `%`*(x: int, y: int): int =\n result = x mod y\n if y > 0 and result < 0: result += y\n if y < 0 and result > 0: result += y\n proc `//`*(x: int, y: int): int{.inline.} =\n result = x div y\n if y > 0 and result * y > x: result -= 1\n if y < 0 and result * y < x: result -= 1\n proc `%=`(x: var int, y: int): void = x = x%y\n proc `//=`(x: var int, y: int): void = x = x//y\n proc `**`(x: int, y: int): int = x^y\n proc `**=`(x: var int, y: int): void = x = x^y\n proc `^`(x: int, y: int): int = x xor y\n proc `|`(x: int, y: int): int = x or y\n proc `&`(x: int, y: int): int = x and y\n proc `>>`(x: int, y: int): int = x shr y\n proc `<<`(x: int, y: int): int = x shl y\n proc `~`(x: int): int = not x\n proc `^=`(x: var int, y: int): void = x = x ^ y\n proc `&=`(x: var int, y: int): void = x = x & y\n proc `|=`(x: var int, y: int): void = x = x | y\n proc `>>=`(x: var int, y: int): void = x = x >> y\n proc `<<=`(x: var int, y: int): void = x = x << y\n proc `[]`(x: int, n: int): bool = (x and (1 shl n)) != 0\n #便利な変換\n proc `!`(x: char, a = '0'): int = int(x)-int(a)\n #定数\n #[ include cplib/utils/constants ]#\n when not declared CPLIB_UTILS_CONSTANTS:\n const CPLIB_UTILS_CONSTANTS* = 1\n const INF32*: int32 = 100100111.int32\n const INF64*: int = int(3300300300300300491)\n const INF = INF64\n #converter\n\n #range\n iterator range(start: int, ends: int, step: int): int =\n var i = start\n if step < 0:\n while i > ends:\n yield i\n i += step\n elif step > 0:\n while i < ends:\n yield i\n i += step\n iterator range(ends: int): int = (for i in 0..<ends: yield i)\n iterator range(start: int, ends: int): int = (for i in\n start..<ends: yield i)\n\n #joinが非stringでめちゃくちゃ遅いやつのパッチ\n proc join*[T: not string](a: openArray[T], sep: string = \"\"): string = a.mapit($it).join(sep)\n" var N = ii() var A = lii(2*N) var B = lii(2*N) var X : seq[(int,int,int)] for i in range(2*N): X.add((A[i]+B[i],A[i],B[i])) X.sort() var memo = newseqwith(2*N+1,newseqwith(2*N+1,-INF)) proc dfs(l,r,c:int):int= if memo[l][r] != -INF: return memo[l][r] if l == r: return 0 result = INF var tmp = 0 if c%2 == 1: result.min = -dfs(l+1,r,c+1) + X[l][2] result.min = -dfs(l,r-1,c+1) + X[r-1][2] else: result.min = -dfs(l+1,r,c+1) + X[l][1] result.min = -dfs(l,r-1,c+1) + X[r-1][1] memo[l][r] = result echo dfs(0,2*N,0)