結果
| 問題 |
No.1470 Mex Sum
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-05-16 19:26:41 |
| 言語 | Nim (2.2.0) |
| 結果 |
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 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 49 |
コンパイルメッセージ
/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