Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. int main(){
  8. int s, n;
  9. cin >> s >> n;
  10. int i, a[n], k = 0, m = 0;
  11. for (i = 0; i < n; ++i){
  12. cin >> a[i];
  13. m = m + a[i];
  14. if (a[i] < s - k){
  15. k = k + a[i];
  16. }
  17. }
  18. cout << k << endl << m - k;
  19. return 0;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement