RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
USACO0316 파일 입출력

Hoofball

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

의견: 0

설명

In preparation for the upcoming hoofball tournament, Farmer John is drilling his
\(N\) cows (conveniently numbered \(1\dots N\), where \(1 \leq N \leq 100\)) in
passing the ball. The cows are all standing along a very long line on one side
of the barn, with cow \(i\) standing \(x_i\) units away from the barn
(\(1 \leq x_i \leq 1000\)). Each cow is standing at a distinct location.

At the beginning of the drill, Farmer John will pass several balls to different
cows. When cow \(i\) receives a ball, either from Farmer John or from another cow,
she will pass the ball to the cow nearest her (and if multiple cows are the same
distance from her, she will pass the ball to the cow farthest to the left among
these). So that all cows get at least a little bit of practice passing, Farmer
John wants to make sure that every cow will hold a ball at least once. Help him
figure out the minimum number of balls he needs to distribute initially to
ensure this can happen, assuming he hands the balls to an appropriate initial
set of cows.

Problem credits: Dhruv Rohatgi

제약

Problem credits: Dhruv Rohatgi

입력 형식

The first line of input contains \(N\). The second line contains \(N\)
space-separated integers, where the \(i\)th integer is \(x_i\).

출력 형식

Please output the minimum number of balls Farmer John must initially pass to the
cows, so that every cow can hold a ball at least once.

파일 입력 / 출력
이 문제는 표준 입출력을 사용하지 않습니다. 프로그램은 다음 파일을 읽고 써야 합니다:
입력을 읽을 파일 hoofball.in
출력을 쓸 파일 hoofball.out
예제 1
입력
5
7 1 3 11 4
출력
2
설명

In the above example, Farmer John should pass a ball to the cow at \(x=1\) and
pass a ball to the cow at \(x=11\). The cow at \(x=1\) will pass her ball to the cow
at \(x=3\), after which this ball will oscillate between the cow at \(x=3\) and the
cow at \(x=4\). The cow at \(x=11\) will pass her ball to the cow at \(x=7\), who will
pass the ball to the cow at \(x=4\), after which this ball will also cycle between
the cow at \(x=3\) and the cow at \(x=4\). In this way, all cows will be passed a
ball at least once (possibly by Farmer John, possibly by another cow).

It can be seen that there is no single cow to whom Farmer John could initially pass a ball
so that every cow would eventually be passed a ball.

문제 정보

riseoj 작성

출처 올림피아드 > USACO > 2017-2018 > February > Bronze

태그

평가 및 의견

Hoofball

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

Log in to rate problems.

개별 의견

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

풀이 제출

Hoofball

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