Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #include <vector>
- #include <algorithm>
- #include <cmath>
- #include <iomanip>
- using namespace std;
- typedef long long ll;
- vector<ll> l;
- ll k, k2;
- ll s(ll c)
- {
- return k + k2 * c*c - c*c*c*c;
- }
- bool isLeft(int i)
- {
- return i + 1 < l.size() ? (s(l[i]) <= s(l[i + 1])) : (s(l[i]) >= s(l[i - 1]));
- }
- int main()
- {
- ifstream in("input.txt");
- int n; in >> n;
- l.resize(n);
- for(int i = 0; i < n; i++) in >> l[i];
- in.close();
- sort(l.begin(), l.end());
- long long max_s = -1000000000;
- for(int i = 0; i < n - 2; i++)
- for(int j = i + 1; j < n - 1; j++)
- {
- ll a = l[i];
- ll b = l[j];
- k = -b*b*b*b + 2*a*a*b*b - a*a*a*a;
- k2 = 2*a*a + 2*b*b;
- int l_r = j + 1, r_r = n - 1;
- while(l_r != r_r)
- {
- if(r_r - 1 == l_r)
- if(s(l[l_r]) > s(l[r_r]))
- r_r = l_r;
- else l_r = r_r;
- else
- {
- int m = (l_r + r_r) / 2;
- if(isLeft(m)) l_r = m;
- else r_r = m;
- }
- }
- max_s = max(max_s, s(l[l_r]));
- }
- ofstream out("output.txt");
- if(max_s < 0) out << "Triangle not found\n";
- else out << fixed << setprecision(3) << sqrt(((long double)max_s) / 16.0) << "\n";
- out.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement