Submission #74153

#TimeUsernameProblemLanguageResultExecution timeMemory
74153renatsjDetecting Molecules (IOI16_molecules)C++14
46 / 100
1071 ms5728 KiB
#include<bits/stdc++.h> #include "molecules.h" struct masivs{int val;int poz;}; masivs ab[1000006]; using namespace std; int i,j,n,m,mas[1000006][2]; vector<int> xx; bool c1(masivs maz,masivs liel) { if (maz.val==liel.val) { return maz.poz<liel.poz; } return maz.val<liel.val; } vector<int> find_subset(int l, int u, vector<int> w) { i=0; while (i<=u) { mas[i][0]=-1; i++; } i=l; while (i<=u) { mas[i][0]=-2; i++; } i=0; n=w.size(); while (i<n) { ab[i].val=w[i]; ab[i].poz=i; i++; } sort(ab,ab+n,c1); i=n-1; while (i>=0) { j=0; while (j+ab[i].val<=u) { if (mas[j+ab[i].val][0]!=-1&&mas[j][0]==-1) { //cout << i << " " << ab[i].val << " " << ab[i].poz << " " << j << "\n"; mas[j][0]=j+ab[i].val; mas[j][1]=ab[i].poz; } j++; } if (mas[0][0]!=-1) { j=0; while (j<l) { xx.push_back(mas[j][1]); j=mas[j][0]; } return xx; } i--; } return vector<int>(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...