포럼
문제 ICPC00378

I. Investigating Frog Behaviour on Lily Pad Patterns

설명

Recently, the biologist Ina discovered a new frog species on the lily pads of a pond. She observed the frogs for a while and found them to be very conscious about their personal space because they avoided sharing a lily pad with other frogs. Also, they seemed quite lazy as they did not move often, and if they did, they always jumped to the nearest empty lily pad.

To confirm her hypotheses about the frogs' movement pattern, Ina set up a large number of lily pads in a pool in her laboratory, arranged in a straight line. Since the frogs were attracted to light, she was able to simplify the test setup further by placing a bright light at one end of that line. This way, the frogs would always jump in one direction (towards the light).

Of course, Ina could now place some frogs on the lily pads and sit there all day watching the frogs jump around. But as the frogs move so rarely, it would take ages to gather a sufficient amount of data.

She therefore attached to each frog a tiny device that could log all jumps of that frog. This way, she could put the frogs on the lily pads, leave them alone for a few hours and come back later to collect the data. Unfortunately, the devices had to be so tiny that there was no space for a position tracking system; instead, the devices could only record the times of the jumps.

But if the movement pattern of the frogs is as restricted as Ina thinks, surely the individual movements of the frog can be reconstructed only from the initial positions and the recorded jump time stamps?

제약
입력 형식

The input consists of:
- One line with an integer \(n\) (\(1\leq n \leq 2\cdot10^5\)), the number of frogs.
- One line with \(n\) integers \(x_1,\dots, x_n\) (\(1\leq x_i \leq 10^6\)), the number of the lily pad on which the \(i\)th frog initially sits. The lily pads are numbered consecutively, starting at \(1\). It is guaranteed that the initial positions are strictly increasing, i.e. \(x_1 < x_2 < \dots < x_n\).
- One line with an integer \(q\) (\(1\leq q \leq 2\cdot10^5\)), the number of jumps recorded.
- \(q\) lines, each containing an integer \(i\) (\(1\leq i\leq n\)), indicating that the \(i\)th frog jumped. The jumps are given in chronological order and you may assume that a jumping frog lands before the next jump begins. The frogs always jump to the nearest empty lily pad with a larger number, and you may assume that such a lily pad always exists.

출력 형식

For each jump, output the number of the lily pad the frog lands on.

예제 1
입력
5
1 2 3 5 7
3
1
2
4
출력
4
6
8
예제 2
입력
5
1 2 3 5 7
4
1
1
1
1
출력
4
6
8
9
문제 정보

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

출처 ICPC GCPC 2023

평가 및 의견

I. Investigating Frog Behaviour on Lily Pad Patterns

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

Log in to rate problems.

개별 의견

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

풀이 제출

I. Investigating Frog Behaviour on Lily Pad Patterns

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