This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int k;
vector<pair<int, int>> v;
int main() {
cin.tie(0) -> sync_with_stdio(false);
cin >> k;
for(int i = 1; i <= k; i++) {
int q;
cin >> q;
for(int j = 0; j < q; j++) {
int x;
cin >> x;
v.emplace_back(x, i);
}
}
sort(v.begin(), v.end());
vector<int> maxi(k + 1, -1);
int max1 = 1, max2 = 2, max3 = 3;
for(int i = 0; i < v.size(); i++) {
int a, b;
if(max1 == v[i].second) a = max2, b = max3;
else if(max2 == v[i].second) a = max1, b = max3;
else a = max1, b = max2;
if(v[i].first < maxi[a] + maxi[b]) {
cout << a << " " << maxi[a] << " " << b << " " << maxi[b] << " " << v[i].second << " " << v[i].first << endl;
return 0;
}
maxi[v[i].second] = v[i].first;
if(v[i].second != max1 and v[i].second != max2 and v[i].second != max3) {
swap(max2, max3);
swap(max1, max2);
max1 = v[i].second;
}
else {
if(maxi[max3] > maxi[max2]) swap(max2, max3);
if(maxi[max2] > maxi[max1]) swap(max1, max2);
}
}
cout << "NIE" << endl;
return 0;
}
Compilation message (stderr)
pat.cpp: In function 'int main()':
pat.cpp:22:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
22 | for(int i = 0; i < v.size(); i++) {
| ~~^~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |