Submission #1134079

#TimeUsernameProblemLanguageResultExecution timeMemory
1134079SonicMLSticks (POI11_pat)C++20
100 / 100
321 ms8688 KiB
#include <iostream> #include <vector> #include <algorithm> using namespace std; struct Stick { int leng; int type; }; bool compareStick(Stick a, Stick b) { return (a.leng < b.leng); } vector <Stick> arr; int const KMAX = 50; int best[1 + KMAX]; int main() { int k; cin >> k; for(int i = 1;i <= k;i++) { int n; cin >> n; for(int j = 0;j < n;j++) { int c; cin >> c; arr.push_back({c, i}); } } sort(arr.begin(), arr.end(), compareStick); for(int i = 0;i < arr.size();i++) { int color = arr[i].type; best[color] = max(best[color], arr[i].leng); Stick best1 = {0, 0}, best2 = {0, 0}; for(int j = 1;j <= k;j++) { if(j != arr[i].type) { if(best1.leng < best[j]) { best2 = best1; best1 = {best[j], j}; }else if(best2.leng < best[j]){ best2 = {best[j], j}; } } } if(best1.leng + best2.leng > arr[i].leng) { cout << best1.type << ' ' << best1.leng << ' ' << best2.type << ' ' << best2.leng << ' ' << arr[i].type << ' ' << arr[i].leng; return 0; } } cout << "NIE\n"; return 0; }
#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...