結果

問題 No.2289 順列ソート
ユーザー buey_tbuey_t
提出日時 2023-05-06 12:30:17
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 128 ms / 2,000 ms
コード長 1,086 bytes
コンパイル時間 244 ms
コンパイル使用メモリ 82,556 KB
実行使用メモリ 85,480 KB
最終ジャッジ日時 2024-05-03 01:18:55
合計ジャッジ時間 4,015 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 119 ms
85,208 KB
testcase_01 AC 119 ms
85,204 KB
testcase_02 AC 113 ms
85,104 KB
testcase_03 AC 117 ms
85,112 KB
testcase_04 AC 112 ms
85,256 KB
testcase_05 AC 111 ms
85,232 KB
testcase_06 AC 111 ms
85,348 KB
testcase_07 AC 110 ms
85,128 KB
testcase_08 AC 111 ms
85,140 KB
testcase_09 AC 112 ms
85,156 KB
testcase_10 AC 112 ms
85,132 KB
testcase_11 AC 116 ms
85,176 KB
testcase_12 AC 108 ms
85,188 KB
testcase_13 AC 109 ms
85,112 KB
testcase_14 AC 111 ms
85,232 KB
testcase_15 AC 113 ms
85,108 KB
testcase_16 AC 110 ms
85,480 KB
testcase_17 AC 109 ms
85,236 KB
testcase_18 AC 128 ms
85,152 KB
testcase_19 AC 122 ms
85,336 KB
testcase_20 AC 118 ms
85,104 KB
testcase_21 AC 110 ms
85,304 KB
testcase_22 AC 111 ms
85,184 KB
testcase_23 AC 110 ms
85,144 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import sqrt,sin,cos,tan,ceil,radians,floor,gcd,exp,log,log10,log2,factorial,fsum
from heapq import heapify, heappop, heappush
from bisect import bisect_left, bisect_right
from copy import deepcopy
import copy
import random
from random import randrange
from collections import deque,Counter,defaultdict
from itertools import permutations,combinations
from decimal import Decimal,ROUND_HALF_UP
#tmp = Decimal(mid).quantize(Decimal('0'), rounding=ROUND_HALF_UP)
from functools import lru_cache, reduce
#@lru_cache(maxsize=None)
from operator import add,sub,mul,xor,and_,or_,itemgetter
import sys
input = sys.stdin.readline
# .rstrip()
INF = 10**18
mod1 = 10**9+7
mod2 = 998244353

#DecimalならPython
#再帰ならPython!!!!!!!!!!!!!!!!!!!!!!!!!!


'''



'''

N = int(input())
P = list(map(int, input().split()))

G = [0]*(N+1)
for i in range(N):
    G[P[i]] = i+1

ans = 0
for i in range(N):
    nx = P[i]
    
    if nx == i+1:
        pass
    else:
        ans += 1
        P[G[i+1]-1] = nx
        G[nx] = G[i+1]
        P[i] = i+1

print(ans)




























0