結果
問題 |
No.609 Noelちゃんと星々
|
ユーザー |
|
提出日時 | 2019-01-18 05:18:52 |
言語 | Nim (2.2.0) |
結果 |
AC
|
実行時間 | 37 ms / 2,000 ms |
コード長 | 643 bytes |
コンパイル時間 | 2,896 ms |
コンパイル使用メモリ | 66,916 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-01 10:14:14 |
合計ジャッジ時間 | 4,439 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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() var Y = newSeqWith(n,scan()) Y.sort(cmp) let y0 = Y[0] for i in 0..<Y.len: Y[i] -= y0 var preY = 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