結果

問題 No.1687 What the Heck?
ユーザー FromBooskaFromBooska
提出日時 2023-03-15 22:41:46
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 644 bytes
コンパイル時間 169 ms
コンパイル使用メモリ 81,760 KB
実行使用メモリ 102,968 KB
最終ジャッジ日時 2023-10-18 12:36:47
合計ジャッジ時間 3,052 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,488 KB
testcase_01 AC 38 ms
53,488 KB
testcase_02 AC 37 ms
53,488 KB
testcase_03 AC 37 ms
53,488 KB
testcase_04 AC 38 ms
53,488 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 54 ms
75,036 KB
testcase_10 AC 50 ms
69,512 KB
testcase_11 AC 50 ms
69,596 KB
testcase_12 AC 84 ms
102,932 KB
testcase_13 AC 84 ms
102,932 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

# 後ろの方が得点が高い
# つまり後ろで勝つのが得策、勝つときは1点差で勝てばいい
# また、後攻の最高値だけに負けてあと全部勝つのも可能
# N=1のとき、0
# N=2のとき、[1, 2]なら0、[2, 1]なら1
# N=3のとき以上は最高値だけ負けるとすればいい

N = int(input())
P = list(map(int, input().split()))
if N == 1:
    ans = 0
elif N == 2:
    if P[0] == 1:
        ans = 0
    else:
        ans = 1
else:
    second_point = 0
    for i in range(N):
        if P[i] == N:
            second_point = i+1
            break
    ans = N*(N+1)//2 - second_point*2
print(ans)
0