Advertisement
Guest User

491A-1

a guest
Jun 23rd, 2018
1,790
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.27 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.     int a, b, c, n;
  7.     cin >> a >> b >> c >> n;
  8.  
  9.     int n1 = a - c;
  10.     int n2 = b - c;
  11.     int n3 = c;
  12.     int n4 = n - n1 - n2 - n3;
  13.  
  14.     if (n1 >= 0 && n2 >= 0 && n3 >= 0 && n4 > 0)
  15.         cout << n4;
  16.     else
  17.         cout << -1;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement