Skip to content

Commit 9be7672

Browse files
committed
math transform
1 parent 60de695 commit 9be7672

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

1175.D. Array Splitting.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#include "stdc++.h"
2+
3+
int main() {
4+
ios::sync_with_stdio(false);
5+
int n, k;
6+
cin >> n >> k;
7+
VLL a(n), f(n);
8+
FOR(i, n) cin >> a[i];
9+
partial_sum(ALL(a), f.begin());
10+
LL ans = k * f.back();
11+
f.pop_back();
12+
sort(ALL(f));
13+
ans -= accumulate(f.begin(), f.begin()+k-1, 0ll);
14+
cout << ans << endl;
15+
return 0;
16+
}

0 commit comments

Comments
 (0)