Submission #1031336

#TimeUsernameProblemLanguageResultExecution timeMemory
1031336racsosabeSticks (POI11_pat)C++14
100 / 100
147 ms17844 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...