Logo
(追記) (追記ここまで)

21177번 - No Thanks! 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB22017615178.646%

문제

In the card game “No Thanks,” the deck of cards consists of 36ドル$ cards numbered 1ドル$–36ドル,ドル and players collect cards to their score pile as the game is played. A player’s final score is the sum of the numbers on their collected cards, with one exception: if a player has collected any cards with two or more consecutive numbers, only the smallest number of that group counts toward the score. Your job is to compute the score for a single player’s pile of cards, though here we allow play with a deck much larger than 36ドル$ cards.

입력

The first line contains one integer, $n,ドル representing the number of cards collected. The second line contains $n$ integers representing the numbers on the collected cards. You may assume that 1ドル \le n \le 90 000,ドル all card values are in the range 1ドル \dots 90 000$ inclusive, and no card value is repeated.

출력

Output a single line containing the score for the given set of cards.

제한

예제 입력 1

5
1 7 5 3 4

예제 출력 1

11

예제 입력 2

6
2 1 3 8 4 5

예제 출력 2

9

힌트

출처

ICPC > Regionals > North America > Pacific Northwest Regional > 2020 ICPC Pacific Northwest Region > Division 1 A번

ICPC > Regionals > North America > Pacific Northwest Regional > 2020 ICPC Pacific Northwest Region > Division 2 R번

ICPC > Regionals > North America > Mid-Atlantic Regional > 2020 Mid-Atlantic USA Regional Contest N번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /