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

Škare

설명

Wanting to perfect his scissors using skills, Fran came up with a new exercise. He
got himself a paper strip of length \(n\) centimetres and, of course, a pair of scissors.
He also asked Lana to assist him for the exercise.
Lana will give Fran \(k\) instructions of the following type: "Cut the \(x\)-th strip at
\(l\) centimetres". At the beginning, Fran has one strip. After the first action, he
will have two strips: the first strip \(l\) centimetres long, and the second one \(n - l\)
centimetres long (the remainder of the original strip). After that, Fran will cut
either the first or the second strip - depending on Lana’s instruction. Each time he cuts a strip, the two
new pieces replace the original strip in the sequence.
More formally, suppose Fran has \(m\) strips of lengths \(a_{1}\), \(a_{2}\), ..., \(a_{m}\). If Lana tells him to cut the \(x\)-th strip
at \(l\) centimetres, the new sequence of strip lengths becomes: \(a_{1}\), \(a_{2}\), ..., a_{\(x - 1\)}, l, \(a_{x} - l\), a_{\(x+1\)}, ..., \(a_{m}\).
After performing all cuts, he and Lana want to verify the cutting process. One way to do that is to count
how many distinct strip lengths there are at the end. Your task is to compute this number.

제약
입력 형식

The first line contains two natural numbers \(n\) and \(k\) (\(2 \le n \le 500\), \(1 \le k < n\)), the length of the original
strip and the number of instructions Lana gives Fran.
Each of the following \(k\) lines contains two natural numbers \(x_{i}\) and \(l_{i}\) (\(1 \le x_{i} \le i\), \(1 \le l_{i} \le L - 1\), where \(L\)
is the length of the \(x_{i}-th\) strip at that moment). These numbers indicate that Fran should cut the \(x_{i}-th\)
strip at \(l_{i}\) centimetres (counting strips from the beginning).

출력 형식

In the first and only line, write one number - the number of distinct strip lengths that Fran will be left
with after he performs all the cuttings.

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

1

9점

\(k \le 3\)

2

6점

\(l_{i} = 1\) for all \(i = 1\), ..., k

3

13점

\(x_{i} = i\) for all \(i = 1\), ..., k

4

22점

No additional constraints.

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

Clarification of the first example:
[5] →[2, 3]
Clarification of the second example:
[6] →[4, 2] →[4, 2] →[2, 2, 2]
Clarification of the third example:
[10] →[2, 8] →[2, 8] →[2, 3, 5] →[2, 3, 5] →[2, 3, 2, 3]

문제 정보

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

출처 COCI 2025/2026 Contest 5

평가 및 의견

Škare

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

Log in to rate problems.

개별 의견

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

풀이 제출

Škare

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