結果
問題 | No.1470 Mex Sum |
ユーザー | yuly3 |
提出日時 | 2021-05-16 19:26:41 |
言語 | Nim (2.0.2) |
結果 |
AC
|
実行時間 | 30 ms / 2,000 ms |
コード長 | 993 bytes |
コンパイル時間 | 4,262 ms |
コンパイル使用メモリ | 73,924 KB |
実行使用メモリ | 15,684 KB |
最終ジャッジ日時 | 2024-10-05 04:45:54 |
合計ジャッジ時間 | 6,615 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,816 KB |
testcase_01 | AC | 1 ms
6,816 KB |
testcase_02 | AC | 4 ms
6,816 KB |
testcase_03 | AC | 4 ms
6,820 KB |
testcase_04 | AC | 4 ms
6,816 KB |
testcase_05 | AC | 4 ms
6,824 KB |
testcase_06 | AC | 4 ms
6,820 KB |
testcase_07 | AC | 4 ms
6,816 KB |
testcase_08 | AC | 4 ms
6,816 KB |
testcase_09 | AC | 4 ms
6,820 KB |
testcase_10 | AC | 4 ms
6,820 KB |
testcase_11 | AC | 5 ms
6,816 KB |
testcase_12 | AC | 30 ms
15,544 KB |
testcase_13 | AC | 26 ms
15,444 KB |
testcase_14 | AC | 26 ms
15,608 KB |
testcase_15 | AC | 27 ms
15,568 KB |
testcase_16 | AC | 25 ms
15,436 KB |
testcase_17 | AC | 26 ms
15,452 KB |
testcase_18 | AC | 26 ms
15,532 KB |
testcase_19 | AC | 26 ms
15,460 KB |
testcase_20 | AC | 26 ms
15,636 KB |
testcase_21 | AC | 27 ms
15,576 KB |
testcase_22 | AC | 26 ms
15,464 KB |
testcase_23 | AC | 27 ms
15,592 KB |
testcase_24 | AC | 27 ms
15,468 KB |
testcase_25 | AC | 26 ms
15,560 KB |
testcase_26 | AC | 27 ms
15,412 KB |
testcase_27 | AC | 27 ms
15,620 KB |
testcase_28 | AC | 27 ms
15,480 KB |
testcase_29 | AC | 27 ms
15,456 KB |
testcase_30 | AC | 26 ms
15,544 KB |
testcase_31 | AC | 28 ms
15,684 KB |
testcase_32 | AC | 29 ms
15,588 KB |
testcase_33 | AC | 28 ms
15,408 KB |
testcase_34 | AC | 27 ms
15,560 KB |
testcase_35 | AC | 28 ms
15,456 KB |
testcase_36 | AC | 27 ms
15,452 KB |
testcase_37 | AC | 20 ms
15,060 KB |
testcase_38 | AC | 20 ms
15,196 KB |
testcase_39 | AC | 20 ms
15,164 KB |
testcase_40 | AC | 23 ms
15,100 KB |
testcase_41 | AC | 22 ms
15,084 KB |
testcase_42 | AC | 23 ms
15,260 KB |
testcase_43 | AC | 23 ms
15,144 KB |
testcase_44 | AC | 23 ms
15,084 KB |
testcase_45 | AC | 23 ms
15,084 KB |
testcase_46 | AC | 22 ms
15,044 KB |
testcase_47 | AC | 22 ms
15,100 KB |
testcase_48 | AC | 22 ms
15,020 KB |
testcase_49 | AC | 22 ms
15,080 KB |
testcase_50 | AC | 20 ms
15,032 KB |
コンパイルメッセージ
/home/judge/data/code/Main.nim(2, 3) Warning: imported and not used: 'algorithm' [UnusedImport] /home/judge/data/code/Main.nim(2, 14) Warning: imported and not used: 'bitops' [UnusedImport] /home/judge/data/code/Main.nim(2, 22) Warning: imported and not used: 'deques' [UnusedImport] /home/judge/data/code/Main.nim(2, 30) Warning: imported and not used: 'heapqueue' [UnusedImport] /home/judge/data/code/Main.nim(3, 31) Warning: imported and not used: 'tables' [UnusedImport] /home/judge/data/code/Main.nim(2, 47) Warning: imported and not used: 'macros' [UnusedImport] /home/judge/data/code/Main.nim(2, 55) Warning: imported and not used: 'sets' [UnusedImport] /home/judge/data/code/Main.nim(3, 24) Warning: imported and not used: 'sugar' [UnusedImport] /home/judge/data/code/Main.nim(3, 3) Warning: imported and not used: 'strformat' [UnusedImport]
ソースコード
import algorithm, bitops, deques, heapqueue, math, macros, sets, sequtils, strformat, strutils, sugar, tables proc input*(): string {.inline.} = stdin.readLine proc inputs*(): seq[string] {.inline.} = stdin.readLine.split proc inputInt*(): int {.inline.} = stdin.readLine.parseInt proc inputInts*(): seq[int] {.inline.} = stdin.readLine.split.map(parseInt) proc chmax*[T: SomeNumber](n: var T, m: T) {.inline.} = n = max(n, m) proc chmin*[T: SomeNumber](n: var T, m: T) {.inline.} = n = min(n, m) proc `%=`*[T: SomeInteger](n: var T, m: T) {.inline.} = n = floorMod(n, m) when isMainModule: var N = inputInt() A = inputInts() var ones, twos: int for ai in A: if ai == 1: ones.inc elif ai == 2: twos.inc var ans = 0 for i, ai in A: if ai == 1: ones.dec ans += 3*twos + 2*(N - twos - (i + 1)) elif ai == 2: twos.dec ans += 3*ones + N - ones - (i + 1) else: ans += 2*ones + N - ones - (i + 1) echo ans