結果
問題 | No.625 ソンタクロース |
ユーザー | yuzupom |
提出日時 | 2017-12-28 19:06:55 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 345 ms / 4,000 ms |
コード長 | 1,301 bytes |
コンパイル時間 | 224 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 11,008 KB |
最終ジャッジ日時 | 2024-12-21 09:06:19 |
合計ジャッジ時間 | 3,211 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 35 ms
10,880 KB |
testcase_01 | AC | 36 ms
10,880 KB |
testcase_02 | AC | 35 ms
10,880 KB |
testcase_03 | AC | 32 ms
10,880 KB |
testcase_04 | AC | 33 ms
10,752 KB |
testcase_05 | AC | 32 ms
10,880 KB |
testcase_06 | AC | 30 ms
10,880 KB |
testcase_07 | AC | 33 ms
10,752 KB |
testcase_08 | AC | 32 ms
10,880 KB |
testcase_09 | AC | 32 ms
10,752 KB |
testcase_10 | AC | 35 ms
10,752 KB |
testcase_11 | AC | 35 ms
10,880 KB |
testcase_12 | AC | 31 ms
10,880 KB |
testcase_13 | AC | 31 ms
10,880 KB |
testcase_14 | AC | 34 ms
10,880 KB |
testcase_15 | AC | 61 ms
10,880 KB |
testcase_16 | AC | 43 ms
10,880 KB |
testcase_17 | AC | 155 ms
10,880 KB |
testcase_18 | AC | 345 ms
11,008 KB |
testcase_19 | AC | 85 ms
10,880 KB |
testcase_20 | AC | 88 ms
10,880 KB |
testcase_21 | AC | 57 ms
10,880 KB |
testcase_22 | AC | 260 ms
11,008 KB |
testcase_23 | AC | 49 ms
10,752 KB |
ソースコード
N,M = map(int,input().split()) ANS = [-1 for i in range(N)] tmp = [] for i in range(N-1, -1, -1): if i == N-4: ans = [x for x in ANS] else: ans = [x for x in tmp] if i == N-1: ANS[i] = M continue if i == N-2: ANS[i] = -1 continue if i == N-3: ANS[i] = M ANS[i+1] = 0 ANS[i+2] = 0 continue if N - i > 2*M + 1: break rest = M required = int((N-i)/2) satisfied = 0 over1 = [] for j in range(N-1, i, -1): if ans[j] < 0: satisfied += 1 ans[j] = 0 elif ans[j] == 0: if satisfied < required: ans[j] = 1 rest -= 1 satisfied += 1 elif ans[j] >= 1: over1.append((ans[j], -j)) ans[j] = 0 if satisfied < required and len(over1) > 0 and rest > 1: over1.sort() while satisfied < required and len(over1) > 0: p,n = over1.pop(0) satisfied += 1 ans[-n] = p+1 rest -= p+1 if rest >= 0 and satisfied >= required: ans[i] = rest tmp = [x for x in ans] ANS = [x for x in ans] else: tmp = [x for x in ans] print(' '.join(map(str,ANS)))