結果

問題 No.1837 Same but Different
ユーザー ikomaikoma
提出日時 2022-02-12 00:00:22
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 85 ms / 2,000 ms
コード長 422 bytes
コンパイル時間 1,275 ms
コンパイル使用メモリ 86,752 KB
実行使用メモリ 76,696 KB
最終ジャッジ日時 2023-09-10 07:10:15
合計ジャッジ時間 5,226 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,052 KB
testcase_01 AC 74 ms
71,116 KB
testcase_02 AC 75 ms
71,112 KB
testcase_03 AC 72 ms
71,016 KB
testcase_04 AC 84 ms
76,696 KB
testcase_05 AC 85 ms
76,492 KB
testcase_06 AC 84 ms
76,584 KB
testcase_07 AC 83 ms
76,528 KB
testcase_08 AC 82 ms
76,556 KB
testcase_09 AC 83 ms
76,524 KB
testcase_10 AC 83 ms
76,632 KB
testcase_11 AC 83 ms
76,600 KB
testcase_12 AC 80 ms
76,616 KB
testcase_13 AC 82 ms
76,516 KB
testcase_14 AC 81 ms
76,596 KB
testcase_15 AC 81 ms
76,376 KB
testcase_16 AC 80 ms
76,572 KB
testcase_17 AC 82 ms
76,640 KB
testcase_18 AC 82 ms
76,452 KB
testcase_19 AC 83 ms
76,372 KB
testcase_20 AC 82 ms
76,292 KB
testcase_21 AC 83 ms
76,292 KB
testcase_22 AC 82 ms
76,488 KB
testcase_23 AC 82 ms
76,236 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve(N):
    A = list(range(0,3*N,3))
    B = list(range(7,3*N+7,3))
    if N%3==1:
        A[0]+=1
    elif N%3==2:
        A[0]+=1
        A[1]+=1
    sumA = sum(A)
    sumB = sum(B)
    dif = sumB-sumA
    assert dif%3==0
    i=N-1
    mx = 9999
    while dif>0:
        d = min(dif,mx-A[i])
        A[i]+=d
        mx = A[i]-3
        i-=1
        dif -= d
    print(*A)
    print(*B)
    
N=int(input())
solve(N)
0