結果

問題 No.601 Midpoint Erase
ユーザー むらためむらため
提出日時 2019-01-18 13:17:29
言語 Nim
(2.0.2)
結果
WA  
実行時間 -
コード長 597 bytes
コンパイル時間 2,849 ms
コンパイル使用メモリ 67,192 KB
実行使用メモリ 7,056 KB
最終ジャッジ日時 2023-09-14 02:11:58
合計ジャッジ時間 4,085 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 RE -
testcase_17 RE -
testcase_18 WA -
testcase_19 WA -
testcase_20 RE -
testcase_21 WA -
testcase_22 RE -
testcase_23 WA -
testcase_24 RE -
testcase_25 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
/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, 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 =
  while true:
    var k = getchar_unlocked()
    if k < '0' or k > '9': break
    else: result = 10 * result + k.ord - '0'.ord

proc getNeignborDiff[T](arr:seq[T]) : seq[T] =
  if arr.len == 0 : return @[]
  result = newSeq[T](arr.len()-1)
  for i in 1..<arr.len(): result[i-1] = arr[i] - arr[i-1]

let n = scan()
let k = scan()
let A = newSeqWith(n,scan()).sorted(cmp)
let B = A.getNeignborDiff().sorted(cmp)
echo B[0..<(n-k)].sum()
0