RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
COCI00349

Kriza

Unrated 레이팅 미적용
난이도
1s
시간 제한
64MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

\(7^{th}\) round, March \(7^{th}\) 2015
The state of the economy is bad, the crysis is striking the country and people are losing their jobs.
However, Sisyphus, the main hero of this task, has found himself a new job.
Starting next mon-
day, Sisyphus will be an assistant locksmith in a hotel. Naturally, first he needs to demonstrate his
locksmithing abilities to the head locksmith.
This is why the head locksmith has given Sisyphus \(N\) keys on a big round pendant, blindfolded him
and led him into a big room. That room contains \(N\) locked doors, denoted with numbers from 1 to
\(N\). Each of the keys on the pendant unlocks precisely one door.
Sisyphus’ job is to unlock and lock each door again. He does this in a way that he moves along the
wall, not changing direction, until he reaches a door. When he reaches a door, he tries unlocking
it using the first (leftmost) key. In the case when the key doesn’t unlock the door, Sisyphus moves it
to the other (right) side of pendant and repeats this procedure until he finds the right key. His work
is done when he goes through all the doors. The first door Sisyphus unlocked is denoted with 1, the
next with 2, the one after with 3 and so on...
What Sisyphus doesn’t know is that the head locksmith is, in fact, testing his endurance so he led him
into a circular room. Therefore, Sisyphus will, after unlocking and locking the last door, go unlocking
and locking the first door again.
Because he’s a hardworking and persistent fellow, Sisyphus has
been doing this job for hours and hours without saying a single word. Only after the \(K\)^{th} successful
unlocking and locking of a door he spoke: "If only I knew how many times so far I’ve put a wrong key
in a door’s lock!" Your task is to answer his question!

제약

In test cases worth 40% of total points, it will hold 1 ⩽N, K ⩽1 000.
In test cases worth 60% of total points, it will hold 1 ⩽\(K\) ⩽50 000.
\(7^{th}\) round, March \(7^{th}\) 2015

입력 형식

The first line of input contains the integers \(N\) (1 ⩽\(N\)\(10^{5}\)) and \(K\) (1 ⩽\(K\)\(10^{9}\)) from the task.
The \(i\)^{th} of the following \(N\) lines contains the integer \(v_{i}\) (1 ⩽\(v_{i}\)\(N\)) which denotes that the \(i\)^{th} key
on the pendant (from left to right) unlocks the door \(v_{i}\).

출력 형식

The first and only line of output must contain an integer representing the answer to Sisyphus’ question.

예제 1
입력
3 5
1
2
3
4 6
4
2
1
3
10 7
1
3
2
4
5
7
6
8
9
10
출력
output
output
4
13
25
설명

Clarification of the second example:
The first locking/unlocking (door 1) – keys (left to right): 4 2 1 3
The second locking/unlocking (door 2) – keys (left to right): 1 3 4 2
The third locking/unlocking (door 3) – keys (left to right): 2 1 3 4
The fourth locking/unlocking (door 4) – keys (left to right): 3 4 2 1
The fifth locking/unlocking (door 1) – keys (left to right): 4 2 1 3
The sixth locking/unlocking (door 2) – keys (left to right): 1 3 4 2
The misplaced keys are underlined.

문제 정보

생성자가 기록되지 않았습니다.

출처 COCI 2014/2015 Contest 7

평가 및 의견

Kriza

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

Kriza

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8