Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- using ll = long long;
- using ld = long double;
- using ull = unsigned long long;
- bool typetest;
- inline void fastIOfileinput()
- {
- ios::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);
- typetest = 0;
- }
- const int N = 1e5 + 1;
- int k;
- vector<pair<ll, int>> s;
- vector<int> a;
- ll len[50];
- void Read()
- {
- cin >> k;
- for (int i = 1; i <= k; ++i)
- {
- int n;
- cin >> n;
- while (n--)
- {
- int v;
- cin >> v;
- s.push_back({v, i});
- }
- }
- sort(s.begin(), s.end());
- }
- void Solve()
- {
- int m = 0;
- for (auto i : s)
- {
- len[i.second] = i.first;
- a.push_back(i.second);
- sort(a.begin(), a.end(), [&](const int &x, const int &y) {
- return len[x] > len[y];
- });
- a.resize(unique(a.begin(), a.end()) - a.begin());
- if (a.size() > 3)
- a.pop_back();
- if (a.size() == 3 && len[a[1]] + len[a[2]] > len[a[0]])
- {
- cout << a[0] << " " << len[a[0]] << " " << a[1] << " " << len[a[1]] << " " << a[2] << " " << len[a[2]];
- return;
- }
- }
- cout << "NIE";
- }
- int32_t main()
- {
- fastIOfileinput();
- if (typetest)
- {
- int t;
- cin >> t;
- for (int v = 1; v <= t; ++v)
- {
- Read();
- Solve();
- }
- }
- else
- {
- Read();
- Solve();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment