103462: [Atcoder]ABC346 C - Σ

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:14 Solved:0

Description

Score: $250$ points

Problem Statement

You are given a sequence of positive integers $A=(A_1,A_2,\dots,A_N)$ of length $N$ and a positive integer $K$.

Find the sum of the integers between $1$ and $K$, inclusive, that do not appear in the sequence $A$.

Constraints

  • $1\leq N \leq 2\times 10^5$
  • $1\leq K \leq 2\times 10^9$
  • $1\leq A_i \leq 2\times 10^9$
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

$N$ $K$
$A_1$ $A_2$ $\dots$ $A_N$

Output

Print the answer.


Sample Input 1

4 5
1 6 3 1

Sample Output 1

11

Among the integers between $1$ and $5$, three numbers, $2$, $4$, and $5$, do not appear in $A$.

Thus, print their sum: $2+4+5=11$.


Sample Input 2

1 3
346

Sample Output 2

6

Sample Input 3

10 158260522
877914575 24979445 623690081 262703497 24979445 1822804784 1430302156 1161735902 923078537 1189330739

Sample Output 3

12523196466007058

Input

Output

得分:250分

问题描述

给你一个长度为N的正整数序列A=$(A_1,A_2,\dots,A_N)$和一个正整数K。

找出1到K之间(包括1和K)没有出现在序列A中的整数的和。

限制条件

  • $1\leq N \leq 2\times 10^5$
  • $1\leq K \leq 2\times 10^9$
  • $1\leq A_i \leq 2\times 10^9$
  • 所有输入值都是整数。

输入

输入将从标准输入按以下格式给出:

$N$ $K$
$A_1$ $A_2$ $\dots$ $A_N$

输出

打印答案。


样例输入1

4 5
1 6 3 1

样例输出1

11

在1到5之间的整数中,有三个数字,2、4和5,没有出现在A中。

因此,打印它们的和:$2+4+5=11$。


样例输入2

1 3
346

样例输出2

6

样例输入3

10 158260522
877914575 24979445 623690081 262703497 24979445 1822804784 1430302156 1161735902 923078537 1189330739

样例输出3

12523196466007058

加入题单

算法标签: