Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define ll long long
- using namespace std;
- int main() {
- ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
- ll n, k;
- cin >> n >> k;
- vector<ll>v(n);
- for (int i=0; i<n; i++) {
- cin >> v[i];
- }
- sort (v.rbegin(), v.rend());
- ll ans=0;
- for (int i=0; i<k; i++) {
- ans+=v[i];
- }
- cout << ans << endl;
- ll x=n%k;
- while (x--) {
- cout << n/k+1 << " ";
- }
- x=k-n%k;
- while (x--) {
- cout << n/k << " ";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment