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

Tabovi

Gold III 골드 III
난이도
1s
시간 제한
32MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

Zvonkec is yet another programmer employed in a small company. Every day he has to refactor one file of source code. Much to his dismay, the source is usually far from being clear and tidy. He is especially bothered by uneven indentation, i.e. the number of tabulators (tabs) indenting each line.

Fortunately, his editor has a command to select a group of consecutive lines and add or delete a character from the start of each one. Help Zvonkec tidy up the code as quickly as possible.

You are given the number of lines \(N\), a sequence specifying the current number of tabs at the start of each line, and a sequence specifying the required number of tabs at the start of each line.

Zvonkec can execute any number of commands consisting of:

  • selecting any number of consecutive lines
  • adding or deleting a single tab to/from the front of each of the selected lines

The two actions above comprise a single command, regardless of the number of selected lines.

It should be noted that it is forbidden to delete more tabs from a line than are actually present at the start of a line, as the editor would start deleting characters other than tabs.

You are asked to calculate the minimum number of commands required to tidy up the code.

제약

Test cases worth 70% of total points have N not greater than 100.

입력 형식

The first line of input contains a positive integer \(N\) (\(N \le 1000\)).

The second line contains a sequence of \(N\) integers \(P_i\) (\(0 \le P_i \le 80\)), specifying the number of tabs at the start of the \(i\)-th line before any editing.

The third line contains a sequence of \(N\) integers \(K_i\) (\(0 \le K_i \le 80\)), specifying the number of tabs that Zvonkec would like at the start of the \(i\)-th line.

출력 형식

The first and only line of output must contain the required number, as specified in the problem statement.

Scoring: Test cases worth \(70\%\) of total points have \(N\) not greater than \(100\).

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

Test 1

10점

None

Test 2

10점

None

Test 3

10점

None

Test 4

10점

None

Test 5

10점

None

Test 6

10점

None

Test 7

10점

None

Test 8

10점

None

Test 9

10점

None

Test 10

10점

None

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

riseoj 작성

출처 COCI 2010/2011 Contest 1

평가 및 의견

Tabovi

개요
출제자 난이도 Gold III 골드 III 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

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

풀이 제출

Tabovi

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