포럼
문제 ICPC00253

C. Code Cleanups

설명

The management of the software company JunkCode has recently found, much to their surprise and disappointment, that productivity has gone down since they implemented their enhanced set of coding guidelines. The idea was that all developers should make sure that every code change they push to the master branch of their software repository strictly follows the coding guidelines. After all, one of the developers, Perikles, has been doing this since long before these regulations became effective so how hard could it be?

Rather than investing a lot of time figuring out why this degradation in productivity occurred, the line manager suggests that they loosen their requirement: developers can push code that weakly violates the guidelines as long as they run cleanup phases on the code from time to time to make sure the repository is tidy.

She suggests a metric where the "dirtiness" of a developer's code is the sum of the pushes that violate the guidelines – so-called dirty pushes – made by that developer, each weighted by the number of days since it was pushed. The number of days since a dirty push is a step function that increases by one each midnight following the push. Hence, if a developer has made dirty pushes on days \(1\), \(2\), and \(5\), the dirtiness on day \(6\) is \(5+4+1=10\). She suggests that a cleanup phase, completely fixing all violations of the coding guidelines, must be completed before the dirtiness reaches \(20\). One of the developers, Petra, senses that this rule must be obeyed not only because it is a company policy. Breaking it will also result in awkward meetings with a lot of concerned managers who all want to know why she cannot be more like Perikles? Still, she wants to run the cleanup phase as seldomly as possible, and always postpones it until it is absolutely necessary. A cleanup phase is always run at the end of the day and fixes every dirty push done up to and including that day. Since all developers are shuffled to new projects at the start of each year, no dirtiness should be left after midnight at the end of new year's eve.

제약
입력 형식

The first line of input contains an integer \(n\) (\(1 \leq n \leq 365\)), the number of dirty pushes made by Petra during a year. The second line contains \(n\) integers \(d_1, d_2, \ldots, d_n\) (\(1 \leq d_i \leq 365\) for each \(1 \le i \le n\)) giving the days when Petra made dirty pushes. You can assume that \(d_i < d_j\) for \(i < j\).

출력 형식

Output the total number of cleanup phases needed for Petra to keep the dirtiness strictly below \(20\) at all times.

예제 1
입력
5
1 45 65 84 346
출력
4
예제 2
입력
3
310 330 350
출력
3
문제 정보

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

출처 ICPC NCPC 2018

평가 및 의견

C. Code Cleanups

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

Log in to rate problems.

개별 의견

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

풀이 제출

C. Code Cleanups

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