結果

問題 No.831 都市めぐり
ユーザー miyaponmiyapon
提出日時 2019-05-24 22:05:11
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 984 ms / 2,000 ms
コード長 785 bytes
コンパイル時間 1,302 ms
コンパイル使用メモリ 11,936 KB
実行使用メモリ 111,884 KB
最終ジャッジ日時 2023-10-17 12:36:56
合計ジャッジ時間 5,406 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,100 KB
testcase_01 AC 29 ms
10,100 KB
testcase_02 AC 29 ms
10,100 KB
testcase_03 AC 28 ms
10,100 KB
testcase_04 AC 29 ms
10,100 KB
testcase_05 AC 29 ms
10,100 KB
testcase_06 AC 29 ms
10,148 KB
testcase_07 AC 31 ms
10,292 KB
testcase_08 AC 33 ms
10,492 KB
testcase_09 AC 29 ms
10,172 KB
testcase_10 AC 33 ms
10,528 KB
testcase_11 AC 32 ms
10,476 KB
testcase_12 AC 74 ms
15,032 KB
testcase_13 AC 66 ms
14,240 KB
testcase_14 AC 79 ms
15,032 KB
testcase_15 AC 437 ms
52,804 KB
testcase_16 AC 184 ms
27,852 KB
testcase_17 AC 481 ms
60,968 KB
testcase_18 AC 662 ms
76,204 KB
testcase_19 AC 965 ms
108,236 KB
testcase_20 AC 984 ms
111,884 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())

left = N//2
right = N - left

A = [i+1 for i in range(N)]
left = A[:N//2]
right = sorted(A[- N//2:], reverse=True)

ans = 0
len_left = len(left)
if len_left == len(right):
    for i in range(len_left):
        if i == 0:
            ans += left[i]*right[i]

        if i == len_left - 1:
            ans += left[i]*right[i]
            break

        if i != len_left - 1:
            ans += left[i]*right[i+1]
            ans += left[i+1]*right[i]

    print(ans)
else:
    for i in range(len_left):
        if i == 0:
            ans += left[0]*right[0]

        if i == len_left - 1:
            ans += left[i]*right[i+1]
            ans += right[i]*right[i+1]
            break

        ans += left[i]*right[i+1]
        ans += left[i+1]*right[i]

    print(ans)
0