Submission #464417

#TimeUsernameProblemLanguageResultExecution timeMemory
464417prvocisloSticks (POI11_pat)C++17
100 / 100
236 ms18044 KiB
#include <iostream> #include <vector> #include <set> #include <algorithm> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int k; cin >> k; vector<pair<int, int> > v; for (int i = 1; i <= k; i++) { int n; cin >> n; for (int j = 0, len; j < n; j++) { cin >> len; v.push_back({ len, i }); } } sort(v.begin(), v.end()); vector<int> maxi(k+1, -1e9); for (int i = 0; i < v.size(); i++) { int i1 = 0, i2 = 0; for (int j = 1; j <= k; j++) if (j != v[i].second) { if (maxi[j] > maxi[i1]) i2 = i1, i1 = j; else if (maxi[j] > maxi[i2]) i2 = j; } if (maxi[i1] + maxi[i2] > v[i].first) { cout << i1 << " " << maxi[i1] << " " << i2 << " " << maxi[i2] << " " << v[i].second << " " << v[i].first << "\n"; return 0; } maxi[v[i].second] = v[i].first; } cout << "NIE\n"; return 0; }

Compilation message (stderr)

pat.cpp: In function 'int main()':
pat.cpp:25:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |  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...