結果

問題 No.2289 順列ソート
ユーザー buey_tbuey_t
提出日時 2023-05-06 12:30:17
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 228 ms / 2,000 ms
コード長 1,086 bytes
コンパイル時間 356 ms
コンパイル使用メモリ 86,808 KB
実行使用メモリ 82,888 KB
最終ジャッジ日時 2023-08-15 13:47:37
合計ジャッジ時間 7,082 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 221 ms
82,488 KB
testcase_01 AC 221 ms
82,844 KB
testcase_02 AC 220 ms
82,640 KB
testcase_03 AC 225 ms
82,764 KB
testcase_04 AC 228 ms
82,452 KB
testcase_05 AC 216 ms
82,636 KB
testcase_06 AC 222 ms
82,632 KB
testcase_07 AC 227 ms
82,604 KB
testcase_08 AC 222 ms
82,608 KB
testcase_09 AC 220 ms
82,776 KB
testcase_10 AC 225 ms
82,636 KB
testcase_11 AC 218 ms
82,760 KB
testcase_12 AC 217 ms
82,564 KB
testcase_13 AC 222 ms
82,640 KB
testcase_14 AC 221 ms
82,756 KB
testcase_15 AC 219 ms
82,336 KB
testcase_16 AC 216 ms
82,452 KB
testcase_17 AC 223 ms
82,888 KB
testcase_18 AC 225 ms
82,344 KB
testcase_19 AC 221 ms
82,628 KB
testcase_20 AC 225 ms
82,764 KB
testcase_21 AC 221 ms
82,608 KB
testcase_22 AC 222 ms
82,792 KB
testcase_23 AC 215 ms
82,604 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