Submission #777489

#TimeUsernameProblemLanguageResultExecution timeMemory
777489JoenPoenManDetecting Molecules (IOI16_molecules)C++17
0 / 100
103 ms65536 KiB
#include "molecules.h"
#include <bits/stdc++.h>

using namespace std;

typedef pair<int, vector<int>> iv;

vector<iv> dp;

std::vector<int> find_subset(int l, int u, std::vector<int> w) {
    dp.push_back({0, {}});
    for (unsigned int i = 0; i < w.size(); i++) {
        for (int j = dp.size()-1; j >= 0; j--) {
            int we; vector<int> contents;
            tie(we, contents) = dp[j];
            if (we+w[i] <= u) {
                contents.push_back(i);
                if (we+w[i] >= l) return contents; 
                dp.push_back({we+w[i], contents});
            }
        }
    }

    return std::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...