G. [语言月赛202208] 数组调整

    Type: RemoteJudge 1000ms 128MiB

[语言月赛202208] 数组调整

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

题目描述

给出一个长度为 nn 的数组,第 ii 个数为 aia_i。

为了调整这个数组,需要将第 kk 个数改变为 −ak-a_k。

请你求出调整后的数组中所有数的和。

输入格式

输入共两行。

输入的第一行为两个整数 n,kn,k。

输入的第二行为 nn 个整数,第 ii 个为 aia_i。

输出格式

输出一行一个整数,代表调整后的数组中所有数的和。

10 7
1 2 3 4 5 6 7 8 9 10
41
5 2
1 999 4 3 2
-989
10 2
1 0 1 1 1 1 1 1 1 1
9

提示

输入输出样例 1 解释

调整后的数组为 1 2 3 4 5 6 -7 8 9 10,和为 41。

输入输出样例 2 解释

调整后的数组为 1 -999 4 3 2,和为 -989。

数据规模与约定

对于 5%5\% 的数据,为输入输出样例 1。

对于另外 40%40\% 的数据,需要调整位置上的数 ak=0a_k=0。

对于另外 20%20\% 的数据,k=1k = 1。

对于 100%100\% 的数据,1≤k≤n,n≤106,0≤ai≤1091 \le k \le n, n \le 10^6,0 \le a_i \le 10^9,其中 aia_i 均为整数。

2026~2027上学期初二1小测

Not Attended
Status
Done
Rule
IOI
Problem
7
Start at
2026-10-26 10:45
End at
2026-10-26 12:15
Duration
1.5 hour(s)
Host
Partic.
32