Submission #4039006
Source Code Expand
from sequtils import map, mapIt from strutils import split, parseInt, parseFloat import macros macro unpack*(input: seq; count: static[int]): untyped = result = quote do: () when NimMinor <= 13: for i in 0..<count: result[0].add quote do: `input`[`i`] else: for i in 0..<count: result.add quote do: `input`[`i`] ## count == 0 のとき unpackしない(seq) ## count > 0 のとき count個分 unpack した結果の tuple を返す type UnselectableTypeError = object of Exception template input*(typ: typedesc; count: Natural = 0): untyped = let line = stdin.readLine.split when count == 0: when typ is int: line.map(parseInt) elif typ is float: line.map(parseFloat) elif typ is string: line else: raise newException(UnselectableTypeError, "You selected a type other than int, float or string") else: when typ is int: line.map(parseInt).unpack(count) elif typ is float: line.map(parseFloat).unpack(count) elif typ is string: line.unpack(count) else: raise newException(UnselectableTypeError, "You selected a type other than int, float or string") template inputs*(typ: typedesc; count = 0; rows = 1): untyped = (1..rows).mapIt(input(typ, count)) # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # template secretEcho*(x: varargs[string, `$`]) = for v in x: stderr.write(v) stderr.writeLine "" template secretEcho*[T](x: seq[seq[T]]) = for v in x: secretEcho v # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # from algorithm import sorted, SortOrder let N = input(int, 1) a = input(int).sorted(cmp = system.cmp, order = Descending) var Alice = 0 Bob = 0 for i, v in a: if i mod 2 == 0: Alice += v else: Bob += v echo Alice - Bob
Submission Info
Submission Time | |
---|---|
Task | B - Card Game for Two |
User | nimon |
Language | Nim (0.13.0) |
Score | 200 |
Code Size | 1834 Byte |
Status | AC |
Exec Time | 1 ms |
Memory | 256 KB |
Compile Error
Hint: system [Processing] Hint: Main [Processing] Hint: sequtils [Processing] Hint: strutils [Processing] Hint: parseutils [Processing] Hint: macros [Processing] Hint: algorithm [Processing] Main.nim(44, 3) Hint: 'N' is declared but not used [XDeclaredButNotUsed] Hint: [Link] Hint: operation successful (14281 lines compiled; 1.974 sec total; 15.153MB; Release Build) [SuccessX]
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 200 / 200 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample_1.txt, sample_2.txt, sample_3.txt |
All | in1.txt, in2.txt, in3.txt, in4.txt, in5.txt, in6.txt, in7.txt, in8.txt, in9.txt, sample_1.txt, sample_2.txt, sample_3.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
in1.txt | AC | 1 ms | 256 KB |
in2.txt | AC | 1 ms | 256 KB |
in3.txt | AC | 1 ms | 256 KB |
in4.txt | AC | 1 ms | 256 KB |
in5.txt | AC | 1 ms | 256 KB |
in6.txt | AC | 1 ms | 256 KB |
in7.txt | AC | 1 ms | 256 KB |
in8.txt | AC | 1 ms | 256 KB |
in9.txt | AC | 1 ms | 256 KB |
sample_1.txt | AC | 1 ms | 256 KB |
sample_2.txt | AC | 1 ms | 256 KB |
sample_3.txt | AC | 1 ms | 256 KB |