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

Prokletnik

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

의견: 0

설명

\(7^{th}\) round, March \(5^{th}\) 2016
Young Luka is about to enter a house with the evil witch Marica inside. As soon as he enters the house,
she asks him questions about her array of \(N\) numbers. Luka fearfully asks for a clarification of the
questions. Marica explains to him that each query consists of two integers \(L\) and \(R\) which represent
the positions of a contiguous s\(ub-ar\)ray in her array.
It is Luka’s task to answer for each query what the longest contiguous s\(ub-ar\)ray of that contigu-
ous s\(ub-ar\)ray (it can be the entire s\(ub-ar\)ray) having the property of being magical. An array is called
magical if all the values are between the values of the first and last number in that array. For example,
[1 3 1 2 4] is magical, the same as [4 1 1 2 1], whereas [3 3 4 1] is not magical.

제약

In test cases worth 50% of total points, it will hold N, Q ⩽30 000.

입력 형식

The first line of input contains the integer \(N\) (1 ⩽\(N\) ⩽500 000), the number of numbers in the array.
The second line contains \(N\) integers \(a@@RISE_MATH_BLOCK_0@@i\)\(10^{9}\)).
The third line contains the integer \(Q\) (1 ⩽\(Q\) ⩽500 000), the number of queries.
Each of the following \(Q\) lines contains two integers, \(L\) and \(R\) (1 ⩽\(L\)\(R\)\(N\)), representing the
s\(ub-ar\)ray from the query.

출력 형식

The \(i\)^{th} line of output must contain a single integer – the answer to the \(i\)^{th} query.

예제 1
입력
5
5 4 3 3 2
3
1 2
1 1
2 4
6
6 6 5 1 6 2
3
4 5
4 6
1 4
출력
output
2
1
3
2
2
4
문제 정보

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

출처 COCI 2015/2016 Contest 7

평가 및 의견

Prokletnik

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

Log in to rate problems.

개별 의견

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

풀이 제출

Prokletnik

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