結果

問題 No.2566 美しい整数列
ユーザー chaemonchaemon
提出日時 2023-12-02 16:40:36
言語 Nim
(2.0.2)
結果
AC  
実行時間 252 ms / 2,000 ms
コード長 15,194 bytes
コンパイル時間 5,349 ms
コンパイル使用メモリ 94,848 KB
実行使用メモリ 32,256 KB
最終ジャッジ日時 2024-09-26 20:35:45
合計ジャッジ時間 9,623 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 220 ms
32,128 KB
testcase_05 AC 252 ms
32,256 KB
testcase_06 AC 155 ms
7,552 KB
testcase_07 AC 165 ms
7,552 KB
testcase_08 AC 159 ms
7,552 KB
testcase_09 AC 159 ms
7,552 KB
testcase_10 AC 158 ms
7,552 KB
testcase_11 AC 173 ms
13,696 KB
testcase_12 AC 175 ms
13,696 KB
testcase_13 AC 172 ms
13,696 KB
testcase_14 AC 178 ms
13,696 KB
testcase_15 AC 171 ms
13,696 KB
testcase_16 AC 188 ms
31,104 KB
testcase_17 AC 198 ms
31,488 KB
testcase_18 AC 200 ms
31,616 KB
testcase_19 AC 130 ms
17,920 KB
testcase_20 AC 191 ms
31,232 KB
testcase_21 AC 192 ms
31,744 KB
testcase_22 AC 118 ms
17,664 KB
testcase_23 AC 159 ms
18,560 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import macros
macro Please(x): untyped = nnkStmtList.newTree()

Please use Nim-ACL
Please use Nim-ACL
Please use Nim-ACL


static:
  when not defined SecondCompile:
    # md5sum: b477dc90d533cf766fe19cb74e825291  atcoder.tar.xz

    template getFileName():string = instantiationInfo().filename
    let fn = getFileName()
    block:
      let (output, ex) = gorgeEx("if [ -e ./atcoder ]; then exit 1; else exit 0; fi")
      # doAssert ex == 0, "atcoder directory already exisits"
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q0Hl5sP4iktleDJdyJZ3UuLSHMFLIaa3sMOntO5DJF0XDp2lMegs4vQRtxTv6hw2ZRyV2r8k/L9p0P2ZYN5WoZSyIh3gs/a27zDkWulbzrxq782h5OfoBmccdk3yzAaRf15eDqyFWdnLTr5k1WUjzj8XNItZY/lRt9+RRrJ7/bp4FBl04aettWcexnRqh4I2IUocuKGACRS4bhb8g4A96py4veOxUIN1XkhICyl6Zln9/ieeicCmQTJf++W8nXBcZtNsdnBtQvHAakVOlDDFXbSdxFhTa7n2RDFfLT0l0Vi5bavu8RkBXMt2croL617SjaPRODeN2L4jKTI6MBIF0XbSLEFJI7kOXUPUpKlv1ZhsbfrLiZDFOwqqAEok0pOCH/4kiNSALJtvatbBLckozVjuzU5IupyCvaFbj+rJBJ32dpnOtdQ4GjOMMLOLNHr0HThqLZae/aP5SbZ5BbpX6ypiemMGtQnDeTpc5Ua6RpUh7EaZMeByFMNh9oNqe+oRcwDWFk2cWvKsNLsasdIEIizLzdojExnCo2m40dv6GQAAAAABiD/F6EYHy4QABnU+A4AMAgCuY17HEZ/sCAAAAAARZWg==\" | base64 -d > atcoder.tar.xz && tar -Jxvf atcoder.tar.xz")
    let (output, ex) = gorgeEx("nim cpp -d:release -d:SecondCompile -d:danger --path:./ --opt:speed --multimethods:on --warning[SmallLshouldNotBeUsed]:off --checks:off -o:a.out " & fn)
    discard staticExec("rm -rf ./atcoder");doAssert ex == 0, output;quit(0)


when defined SecondCompile:
  const DO_CHECK = false;const DEBUG = false
else:
  const DO_CHECK = true;const DEBUG = true
const
  USE_DEFAULT_TABLE = true
  DO_TEST = false

# see https://github.com/zer0-star/Nim-ACL/tree/master/src/atcoder/extra/header/chaemon_header.nim
include atcoder/extra/header/chaemon_header


proc solve() =
  let N, M = nextInt()
  var
    A = Seq[N: nextInt()]
    B = Seq[M: nextInt()]
    C = Seq[N: nextInt()]
    Cs = C.sum
    ans = Cs # 全部変える
  var
    dp = initTable[int, int]()
    s = 0
  for i in N:
    # A[i]を変えない
    # A[0]はA[i] - sになる
    let A0 = A[i] - s
    dp[A0] += C[i] # A[0] = A0にすればC[i]のコスト節約
    s += B[i mod M]
  for A0, s in dp:
    ans.min= Cs - s
  echo ans
  discard

solve()

0