提交时间:2023-11-18 08:23:43
运行 ID: 110960
# include <bits/stdc++.h> using namespace std ; int nums [114514] ; int main ( ) { int n , k ; cin >> n >> k ; for ( int i = 1 ; i <= n ; i ++ ) { cin >> nums [i] ; } sort ( nums + 1 , nums + n + 1 ) ; for ( int i = 1 ; i <= k ; i ++ ) { nums [1] *= -1 ; sort ( nums + 1 , nums + n + 1 ) ; } long long sum = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { sum += nums [i] ; } cout << sum << endl ; return 0 ; }