Dang_Quan_10_Tin

STICKS

Oct 17th, 2020
327
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.48 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. using ll = long long;
  4. using ld = long double;
  5. using ull = unsigned long long;
  6.  
  7. bool typetest;
  8. inline void fastIOfileinput()
  9. {
  10.     ios::sync_with_stdio(0);
  11.     cin.tie(0);
  12.     cout.tie(0);
  13.     typetest = 0;
  14. }
  15.  
  16. const int N = 1e5 + 1;
  17. int k;
  18. vector<pair<ll, int>> s;
  19. vector<int> a;
  20. ll len[50];
  21.  
  22. void Read()
  23. {
  24.     cin >> k;
  25.     for (int i = 1; i <= k; ++i)
  26.     {
  27.         int n;
  28.         cin >> n;
  29.         while (n--)
  30.         {
  31.             int v;
  32.             cin >> v;
  33.             s.push_back({v, i});
  34.         }
  35.     }
  36.     sort(s.begin(), s.end());
  37. }
  38.  
  39. void Solve()
  40. {
  41.     int m = 0;
  42.     for (auto i : s)
  43.     {
  44.         len[i.second] = i.first;
  45.         a.push_back(i.second);
  46.         sort(a.begin(), a.end(), [&](const int &x, const int &y) {
  47.             return len[x] > len[y];
  48.         });
  49.         a.resize(unique(a.begin(), a.end()) - a.begin());
  50.         if (a.size() > 3)
  51.             a.pop_back();
  52.         if (a.size() == 3 && len[a[1]] + len[a[2]] > len[a[0]])
  53.         {
  54.             cout << a[0] << " " << len[a[0]] << " " << a[1] << " " << len[a[1]] << " " << a[2] << " " << len[a[2]];
  55.             return;
  56.         }
  57.     }
  58.     cout << "NIE";
  59. }
  60.  
  61. int32_t main()
  62. {
  63.     fastIOfileinput();
  64.     if (typetest)
  65.     {
  66.         int t;
  67.         cin >> t;
  68.         for (int v = 1; v <= t; ++v)
  69.         {
  70.             Read();
  71.             Solve();
  72.         }
  73.     }
  74.     else
  75.     {
  76.         Read();
  77.         Solve();
  78.     }
  79. }
Advertisement
Add Comment
Please, Sign In to add comment