Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <string>
- using namespace std;
- int main(){
- int s, n;
- cin >> s >> n;
- int i, a[n], k = 0, m = 0;
- for (i = 0; i < n; ++i){
- cin >> a[i];
- m = m + a[i];
- if (a[i] < s - k){
- k = k + a[i];
- }
- }
- cout << k << endl << m - k;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement