제출 #946230

#제출 시각아이디문제언어결과실행 시간메모리
946230attkyDetecting Molecules (IOI16_molecules)C++17
19 / 100
1 ms440 KiB
#include <bits/stdc++.h> using namespace std; struct Molec { long long int poids; int pos; bool operator< (Molec other) { return poids < other.poids; } }; vector<int> find_subset(int l, int u, vector<int> w) { int n = w.size(); vector<Molec> molecules(n); for(int loop = 0; loop < n; ++loop) { molecules[loop] = {w[loop], loop}; } sort(molecules.begin(), molecules.end()); long long int somme = 0; int fin = 0; while(somme <= u && fin < n) { if(somme + molecules[fin].poids <= u) { somme += molecules[fin].poids; fin++; } else { break; } } vector<int> indice; if(l <= somme && somme <= u) { for(int loop = 0; loop < fin; ++loop) { indice.push_back(molecules[loop].pos); } return indice; } for(int loop = fin; loop < u; ++loop) { somme -= molecules[loop-fin].poids; somme += molecules[loop].poids; if(l <= somme && somme <= u) { for(int looping = loop-fin+1; looping <= loop; ++looping) { indice.push_back(molecules[looping].pos); } return indice; } } return indice; }
#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...