結果

問題 No.1604 Swap Sort:ONE
ユーザー moharan627moharan627
提出日時 2021-07-16 21:53:44
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 487 ms / 2,000 ms
コード長 798 bytes
コンパイル時間 146 ms
コンパイル使用メモリ 10,768 KB
実行使用メモリ 8,576 KB
最終ジャッジ日時 2023-09-20 13:43:46
合計ジャッジ時間 8,486 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,776 KB
testcase_01 AC 17 ms
7,776 KB
testcase_02 AC 16 ms
7,736 KB
testcase_03 AC 15 ms
7,772 KB
testcase_04 AC 16 ms
7,772 KB
testcase_05 AC 274 ms
8,436 KB
testcase_06 AC 487 ms
8,516 KB
testcase_07 AC 419 ms
8,568 KB
testcase_08 AC 418 ms
8,524 KB
testcase_09 AC 418 ms
8,512 KB
testcase_10 AC 417 ms
8,504 KB
testcase_11 AC 418 ms
8,576 KB
testcase_12 AC 419 ms
8,468 KB
testcase_13 AC 419 ms
8,516 KB
testcase_14 AC 417 ms
8,532 KB
testcase_15 AC 417 ms
8,516 KB
testcase_16 AC 422 ms
8,520 KB
testcase_17 AC 160 ms
8,172 KB
testcase_18 AC 163 ms
8,304 KB
testcase_19 AC 379 ms
8,492 KB
testcase_20 AC 145 ms
8,300 KB
testcase_21 AC 379 ms
8,488 KB
testcase_22 AC 278 ms
8,288 KB
testcase_23 AC 57 ms
8,204 KB
testcase_24 AC 28 ms
7,776 KB
testcase_25 AC 382 ms
8,488 KB
testcase_26 AC 208 ms
8,236 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
INF = float('inf')
#10**20,2**63,float('inf')
MOD = 10**9 + 7
MOD2 = 998244353
#from collections import defaultdict
def solve():
    def II(): return int(sys.stdin.readline())
    def LI(): return list(map(int, sys.stdin.readline().split()))
    def LC(): return list(input())
    def IC(): return [int(c) for c in input()]
    def MI(): return map(int, sys.stdin.readline().split())
    #N=3000,O(N^2)程度は可能。
    N=II()
    P = LI()
    Ans = 0
    for i in range(N):
        n = i+1
        Ans += P[i] - n
        Dis = P[i] - n
        for j in range(i+1,N):
            if(P[j]-n <= Dis):
                P[j] += 1
        P[i] = n
        #print(P)
    print(Ans)
    return
solve()
#sys.setrecursionlimit(10 ** 6)#再帰関数ではコメントにしないこと!!
0