CSES - Missing Coin Sum

Xem dạng PDF

Gửi bài giải

Điểm: 1,00 (OI)
Giới hạn thời gian: 1.0s
Giới hạn bộ nhớ: 512M
Input: stdin
Output: stdout

Nguồn bài:
https://cses.fi/problemset/task/2183
Dạng bài
Ngôn ngữ cho phép
C, C++, Java, Kotlin, Pascal, PyPy, Python, Scratch

You have ~n~ coins with positive integer values. What is the smallest sum you cannot create using a subset of the coins?

Input

  • The first line has an integer ~n~: the number of coins.

The second line has ~n~ integers ~x\_1,x\_2,\dots,x\_n~: the value of each coin.

Output

  • Print one integer: the smallest coin sum.

Constraints

  • ~1 \le n \le 2 \cdot 10^5~
  • ~1 \le x\_i \le 10^9~

Example Input

5
2 9 1 2 7

Example Output

6

Bình luận

Hãy đọc nội quy trước khi bình luận.


Không có bình luận tại thời điểm này.