lina_os

Untitled

Apr 20th, 2025
10
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #define ll long long
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7. ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  8. ll n, k;
  9. cin >> n >> k;
  10. vector<ll>v(n);
  11. for (int i=0; i<n; i++) {
  12. cin >> v[i];
  13. }
  14. sort (v.rbegin(), v.rend());
  15. ll ans=0;
  16. for (int i=0; i<k; i++) {
  17. ans+=v[i];
  18. }
  19. cout << ans << endl;
  20. ll x=n%k;
  21. while (x--) {
  22. cout << n/k+1 << " ";
  23. }
  24. x=k-n%k;
  25. while (x--) {
  26. cout << n/k << " ";
  27. }
  28. return 0;
  29. }
  30.  
  31.  
Advertisement
Add Comment
Please, Sign In to add comment