結果

問題 No.689 E869120 and Constructing Array 3
ユーザー rlangevinrlangevin
提出日時 2023-07-11 12:03:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 80 ms / 1,000 ms
コード長 665 bytes
コンパイル時間 976 ms
コンパイル使用メモリ 87,040 KB
実行使用メモリ 75,740 KB
最終ジャッジ日時 2023-10-11 03:25:46
合計ジャッジ時間 4,408 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,524 KB
testcase_01 AC 73 ms
71,304 KB
testcase_02 AC 74 ms
71,588 KB
testcase_03 AC 79 ms
75,704 KB
testcase_04 AC 79 ms
75,600 KB
testcase_05 AC 77 ms
75,592 KB
testcase_06 AC 80 ms
75,552 KB
testcase_07 AC 77 ms
75,380 KB
testcase_08 AC 80 ms
75,740 KB
testcase_09 AC 80 ms
75,524 KB
testcase_10 AC 76 ms
75,444 KB
testcase_11 AC 80 ms
75,720 KB
testcase_12 AC 76 ms
75,500 KB
testcase_13 AC 71 ms
71,172 KB
testcase_14 AC 72 ms
71,400 KB
testcase_15 AC 73 ms
71,412 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

K = int(input())
if K == 0:
    print(1)
    print(1)
    exit()

def solve(K):
    a = 0
    while a * (a - 1) //2 <= K:
        b = 0
        while a * (a - 1) //2 + a * b <= K and b <= K:
            c = 0
            while a * (a - 1) //2 + a * b + b * c <= K and c <= K:
                # print(a, b, c)
                if a * (a - 1) //2 + a * b + b * c == K and a + b + c <= 250:
                    return a, b, c
                # if a * (a - 1) //2 + a * b + b * c == 0:
                #     break
                c += 1
            b += 1
        a += 1
    return False

a, b, c = solve(K)
print(a + b + c)
ans = [1] * a + [2] * b + [3] * c
print(*ans)
0