結果
| 問題 | No.609 Noelちゃんと星々 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-01-18 05:15:50 |
| 言語 | Nim (2.2.0) |
| 結果 |
AC
|
| 実行時間 | 38 ms / 2,000 ms |
| コード長 | 630 bytes |
| 記録 | |
| コンパイル時間 | 2,866 ms |
| コンパイル使用メモリ | 67,072 KB |
| 実行使用メモリ | 5,760 KB |
| 最終ジャッジ日時 | 2024-07-01 10:14:10 |
| 合計ジャッジ時間 | 4,841 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 25 |
コンパイルメッセージ
/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]
ソースコード
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