Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define loop(i,from,to) for (int i = from; i < to; ++i)
- #define qAll(q) q.begin(), q.end()
- #define X first
- #define Y second
- #include <bits/stdc++.h>
- using std::cin;
- using std::cout;
- using std::endl;
- using std::vector;
- using std::string;
- using std::pair;
- using std::set;
- const int INF = 1e9+7;
- const double eps = 1e-6;
- template <typename T> void reverse(T &a) {
- long long s = a.size();
- for (long long i = 0; i < s / 2; ++i)
- std::swap(a[i], a[s - i - 1]);
- }
- long long S(int a, int b, int c) {
- long long p = a + b + c;
- return 1LL * p * (p - 2 * a) * (p - 2 * b) * (p - 2 * c);
- }
- bool check(int a, int b, int c) {
- return a + b > c && a + c > b && b + c > a;
- }
- signed main() {
- std::ios::sync_with_stdio(false);
- cin.tie(0);
- cout.tie();
- int n, T; cin >> n;
- vector<int> data;
- loop(i, 0, n) {
- cin >> T;
- data.emplace_back(T);
- }
- if (n < 3) cout << -1;
- else {
- vector< pair<int, int> > sides;
- loop(i, 0, n) sides.push_back({data[i], i + 1});
- std::sort(sides.rbegin(), sides.rend());
- bool f = false;
- long long mx = -INF;
- loop(i, 0, n - 2) {
- int j = i + 1, k = i + 2;
- if (check(sides[i].first, sides[j].first, sides[k].first)) {
- assert(mx <= S(sides[i].first, sides[j].first, sides[k].first));
- if (mx <= 0)
- {
- mx = S(sides[i].first, sides[j].first, sides[k].first);
- cout << std::fixed << std::setprecision(6) <<
- sqrt((long double) mx) / 4 << endl;
- cout << sides[i].second << " " << sides[j].second << " " << sides[k].second;
- f = true;
- }
- }
- }
- if (!f) cout << -1;
- }
- //std::cout << "Hello World!\n";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement