fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4.  
  5. int main() {
  6. int a , b , c ,n;
  7. cin >>a >> b >> c >> n;
  8. if(c <=min(a,b) && a+b-c < n){
  9. cout << n - a - b +c;
  10. }else{
  11. puts("-1");
  12. }
  13. return 0;
  14. }
Success #stdin #stdout 0s 4572KB
stdin
3 3 3 0
stdout
-1