結果
問題 | No.115 遠足のおやつ |
ユーザー | むらため |
提出日時 | 2019-01-23 12:54:39 |
言語 | Nim (2.0.2) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,513 bytes |
コンパイル時間 | 2,904 ms |
コンパイル使用メモリ | 65,548 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-01 10:33:53 |
合計ジャッジ時間 | 4,028 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | AC | 2 ms
6,944 KB |
testcase_05 | AC | 1 ms
6,944 KB |
testcase_06 | WA | - |
testcase_07 | AC | 2 ms
6,940 KB |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | AC | 2 ms
6,944 KB |
testcase_15 | AC | 1 ms
6,944 KB |
testcase_16 | AC | 1 ms
6,940 KB |
testcase_17 | AC | 1 ms
6,944 KB |
testcase_18 | WA | - |
testcase_19 | AC | 2 ms
6,944 KB |
testcase_20 | AC | 1 ms
6,940 KB |
testcase_21 | WA | - |
testcase_22 | AC | 2 ms
6,940 KB |
testcase_23 | WA | - |
testcase_24 | AC | 1 ms
6,940 KB |
testcase_25 | AC | 1 ms
6,940 KB |
testcase_26 | AC | 2 ms
6,944 KB |
testcase_27 | AC | 2 ms
6,940 KB |
testcase_28 | AC | 1 ms
6,944 KB |
testcase_29 | AC | 1 ms
6,940 KB |
testcase_30 | AC | 1 ms
6,940 KB |
testcase_31 | AC | 1 ms
6,940 KB |
testcase_32 | AC | 1 ms
6,944 KB |
testcase_33 | AC | 2 ms
6,940 KB |
testcase_34 | AC | 1 ms
6,940 KB |
testcase_35 | AC | 2 ms
6,940 KB |
testcase_36 | WA | - |
testcase_37 | AC | 1 ms
6,944 KB |
testcase_38 | WA | - |
testcase_39 | WA | - |
testcase_40 | WA | - |
testcase_41 | WA | - |
testcase_42 | AC | 1 ms
6,940 KB |
ソースコード
import sequtils,strutils,algorithm proc getchar_unlocked():char {. importc:"getchar_unlocked",header: "<stdio.h>" .} proc scan(): int = while true: var k = getchar_unlocked() if k < '0': break result = 10 * result + k.ord - '0'.ord proc putchar_unlocked(c:char){. importc:"putchar_unlocked",header: "<stdio.h>" .} proc printInt(a:int32) = if a == 0: putchar_unlocked('0') return template div10(a:int32) : int32 = cast[int32]((0x1999999A * cast[int64](a)) shr 32) template mod10(a:int32) : int32 = a - (a.div10 * 10) var n = a var rev = a var cnt = 0 while rev.mod10 == 0: cnt += 1 rev = rev.div10 rev = 0 while n != 0: rev = rev * 10 + n.mod10 n = n.div10 while rev != 0: putchar_unlocked((rev.mod10 + '0'.ord).chr) rev = rev.div10 while cnt != 0: putchar_unlocked('0') cnt -= 1 proc printInt(a:int,last:char) = a.int32.printInt() putchar_unlocked(last) let n = scan() let sum = scan() let cnt = scan() var ans = toSeq(1..cnt) let sumOfAns = (cnt + 1) * cnt div 2 if sumOfAns > sum : quit "-1",0 var left = sum - sumOfAns # ans:[1 2 3 4 5] に left:200 を振り分けたい, 各ansはn:72を超えない var maxN = n for i in (cnt-1).countdown(0): let diff = left.min(maxN - ans[i]) if diff < 0 : quit "-1",0 if diff == 0 or i == 0: if left == 0 : break quit "-1",0 left -= diff ans[i] += diff maxN = min(ans[i],maxN) - 1 echo ans.mapIt($it).join(" ") # for a in ans : printInt(a,' ') # putchar_unlocked('\n')