結果

問題 No.609 Noelちゃんと星々
ユーザー むらためむらため
提出日時 2019-01-18 05:15:50
言語 Nim
(2.0.2)
結果
AC  
実行時間 35 ms / 2,000 ms
コード長 630 bytes
コンパイル時間 3,248 ms
コンパイル使用メモリ 69,856 KB
実行使用メモリ 6,560 KB
最終ジャッジ日時 2023-09-14 02:08:59
合計ジャッジ時間 5,260 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
5,664 KB
testcase_01 AC 14 ms
4,380 KB
testcase_02 AC 9 ms
4,376 KB
testcase_03 AC 12 ms
4,384 KB
testcase_04 AC 6 ms
4,380 KB
testcase_05 AC 32 ms
6,308 KB
testcase_06 AC 28 ms
5,896 KB
testcase_07 AC 16 ms
4,808 KB
testcase_08 AC 5 ms
4,376 KB
testcase_09 AC 10 ms
4,376 KB
testcase_10 AC 20 ms
5,072 KB
testcase_11 AC 18 ms
4,972 KB
testcase_12 AC 24 ms
5,456 KB
testcase_13 AC 5 ms
4,380 KB
testcase_14 AC 3 ms
4,380 KB
testcase_15 AC 28 ms
5,892 KB
testcase_16 AC 33 ms
6,388 KB
testcase_17 AC 26 ms
5,616 KB
testcase_18 AC 9 ms
4,376 KB
testcase_19 AC 28 ms
5,824 KB
testcase_20 AC 34 ms
6,460 KB
testcase_21 AC 34 ms
6,500 KB
testcase_22 AC 34 ms
6,560 KB
testcase_23 AC 34 ms
6,484 KB
testcase_24 AC 35 ms
6,560 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 54) Warning: imported and not used: 'strformat' [UnusedImport]
/home/judge/data/code/Main.nim(1, 17) Warning: imported and not used: 'strutils' [UnusedImport]
/home/judge/data/code/Main.nim(1, 47) Warning: imported and not used: 'macros' [UnusedImport]
/home/judge/data/code/Main.nim(1, 41) Warning: imported and not used: 'sugar' [UnusedImport]

ソースコード

diff #

import sequtils,strutils,algorithm,math,sugar,macros,strformat

proc getchar_unlocked():char {. importc:"getchar_unlocked",header: "<stdio.h>" .}
proc scan(): int =
  var minus = false
  while true:
    var k = getchar_unlocked()
    if k == '-' : minus = true
    elif k < '0' or k > '9': break
    else: result = 10 * result + k.ord - '0'.ord
  if minus: result *= -1

let n = scan()
let Y0 = newSeqWith(n,scan()).sorted(cmp)
let Y = Y0.mapIt(it - Y0[0])
var preY = Y[0]
var ans = Y.sum()
for i,y in Y:
  let diff = y - preY
  if diff == 0: continue
  let w = 2 * i - n
  if w >= 0 : break
  ans += diff * w
  preY = y
echo ans
0