제출 #419258

#제출 시각아이디문제언어결과실행 시간메모리
419258JeanBombeurDetecting Molecules (IOI16_molecules)C++17
69 / 100
3 ms588 KiB
#include <iostream> #include <cstdio> #include <vector> #include <algorithm> #include "molecules.h" using namespace std; vector<int> find_subset(int inf, int sup, vector<int> Tailles) { vector <pair <int, int>> Molecules; int nbMolecules = 0; for (int a : Tailles) { Molecules.push_back({a, nbMolecules ++}); } sort(Molecules.begin(), Molecules.end()); int sum = 0; int gauche = 0, droite = 0; while (droite < nbMolecules && sum + Molecules[droite].first <= sup) { sum += Molecules[droite ++].first; } while (droite < nbMolecules && sum < inf) { sum += Molecules[droite ++].first - Molecules[gauche ++].first; } if (droite == nbMolecules && sum < inf) return vector<int>(0); vector <int> ans; for (int i = gauche; i < droite; i ++) { ans.push_back(Molecules[i].second); } return ans; }
#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...