fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. //freopen("in.txt","r",stdin);
  7. int x,y;
  8. int a[4];
  9. while((cin >> a[0] >> a[1] >> a[2] >> x >> y) and (a[0]+a[1]+a[2]+x+y != 0) ){
  10. sort(a,a+3);
  11. if(x>y) swap(y,x);
  12.  
  13. if(a[0] <= x ){
  14. if(a[1] <= x )
  15. if(a[2] <= x ) cout << 1 << endl;
  16. else cout << a[1]+1 << endl;
  17. else
  18. if(a[1] <= y) cout << y+1 << endl;
  19. else cout << -1 << endl;
  20. }else cout << -1 << endl;
  21.  
  22.  
  23. }
  24. return 0;
  25. }
  26.  
Success #stdin #stdout 0s 15240KB
stdin
28 51 29 50 52
50 26 19 10 27
10 20 30 24 26
46 48 49 47 50
0 0 0 0 0
stdout
30
-1
21
51