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

Slastičarnica

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

의견: 0

설명

There \(is\) \(a\) new bakery \(in\) town! Come and try delicious cakes from Dodo’s bakery!
The bakers have prepared \(n\) cakes, the \(i-th\) of which has sweetness \(a@@RISE_MATH_BLOCK_0@@i\) cakes whose sweetnesses are at least \(s\)\(i\)”.
Dorijan serves customers in a peculiar way. He will give \(d_{i}\) continuous cakes from
the table. To keep the table looking as nice as possible he will only give cakes from
the left or the right edge of the table. He noticed that he cannot serve a lot of customers that way, so
before serving a customer he will eat some cakes (possibly none) from the edges of the table.
If Dorijan cannot satisfy a customer, he will close the bakery for the day. What is the largest number of
customers he can serve, before closing?

제약

Subtask 1 (21 points): n, \(q \le 100\)

Subtask 2 (31 points): \(d@@RISE_MATH_BLOCK_0@@q = 1\)

Subtask 3 (58 points): No additional constraints.

입력 형식

The first line contains two integers n, q (\(1 \le n \le 5\,000\), \(1 \le q \le 2 \cdot 10^{5}\)), the number of cakes and the
number of people in the line.
The second line contains \(n\) numbers \(a_{i}\) (\(1 \le a_{i} \le 10^{9}\)), where \(a_{i}\) is the sweetness of the \(i-th\) cake.
In each of the next \(q\) lines there are two integers \(d@@RISE_MATH_BLOCK_0@@i\) (\(1 \le d@@RISE_MATH_BLOCK_1@@i \le 10^{9}\)), the order of the \(i-th\)
customer in line.

출력 형식

In the first and only line output the number of customers Dorijan can serve.

서브태스크
서브태스크점수설명

1

21점

n, \(q \le 100\)

2

31점

\(d@@RISE_MATH_BLOCK_0@@q = 1\)

3

58점

No additional constraints.

예제 1
입력
5 6
1 2 3 4 5
1 1
1 2
1 3
1 4
1 6
1 5
출력
4
예제 2
입력
5 3
1 3 2 2 1
3 1
1 3
2 2
출력
2
예제 3
입력
9 5
1 3 2 5 1 4 6 2 1
3 2
2 3
1 1
1 2
1 1
출력
4
설명

Clarification of the third example:
Dorijan first eats one cake from the left, then gives the next three cakes with sweetnesses 3, 2, and 5 to
the first customer. He then eats another cake from the left and gives the next two cakes with sweetnesses
4 and 6 to the second customer. The third customer gets a cake from the right with sweetness 1 and the
fourth gets the last cake with sweetness 2. Dorijan unfortunately does not have more cakes, so the last
customer goes home empty-handed.

문제 정보

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

출처 COCI 2022/2023 Contest 5

평가 및 의견

Slastičarnica

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

Log in to rate problems.

개별 의견

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

풀이 제출

Slastičarnica

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