提交时间:2023-11-18 08:32:15

运行 ID: 110965

#include<bits/stdc++.h> using namespace std; int nums[1001],n,k,ans; int main() { int mi=0x3f3f; cin>>n>>k; for(int i=1;i<=n;i++) {cin>>nums[i];ans+=nums[i]; if(nums[i]<mi) mi=nums[i];} if(k%2==1) {ans-=mi*2;} cout<<ans; }