Advertisement
Guest User

Untitled

a guest
Nov 17th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1.  
  2. #include <bits/stdc++.h>
  3. #define FI first
  4. #define SE second
  5. #define EPS 1e-9
  6. #define ALL(a) a.begin(),a.end()
  7. #define SZ(a) int((a).size())
  8. #define MS(s, n) memset(s, n, sizeof(s))
  9. #define FOR(i,a,b) for (int i = (a); i <= (b); i++)
  10. #define FORE(i,a,b) for (int i = (a); i >= (b); i--)
  11. #define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
  12. //__builtin_ffs(x) return 1 + index of least significant 1-bit of x
  13. //__builtin_clz(x) return number of leading zeros of x
  14. //__builtin_ctz(x) return number of trailing zeros of x
  15.  
  16. using namespace std;
  17. using ll = long long;
  18. using ld = double;
  19. typedef pair<int, int> II;
  20. typedef pair<int, II> III;
  21. typedef complex<ld> cd;
  22. typedef vector<cd> vcd;
  23.  
  24. const ll MODBASE = 1000000007LL;
  25. const int MAXN = 210;
  26. const int MAXM = 100010;
  27. const int MAXK = 110;
  28. const int MAXQ = 200010;
  29.  
  30. int t[10], T, a[10];
  31.  
  32. bool check(int u) {
  33. FOR(i,1,4) a[i] = t[i];
  34. a[5] = u;
  35. sort(a+1, a+6);
  36. return a[2] + a[3] + a[4] <= 3 * T;
  37. }
  38.  
  39. int main() {
  40. ios::sync_with_stdio(0);
  41. cin.tie(nullptr);
  42. ld x;
  43. FOR(i,1,4) {
  44. cin >> x;
  45. t[i] = int(x * 100);
  46. }
  47. cin >> x;
  48. T = int(x * 100);
  49. sort(t+1, t+4+1);
  50. if (t[2] + t[3] + t[4] <= 3 * T) cout << "infinite";
  51. else if (t[1] + t[2] + t[3] > 3 * T) cout << "impossible";
  52. else {
  53. int res = -1;
  54. FOR(i,0,2100)
  55. if (check(i)) res = i;
  56. cout << fixed << setprecision(2) << res / 100.0;
  57. }
  58. return 0;
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement