Submission #1020480

#TimeUsernameProblemLanguageResultExecution timeMemory
1020480vjudge1Detecting Molecules (IOI16_molecules)C++17
46 / 100
1068 ms2396 KiB
#include <bits/stdc++.h>
#include "molecules.h"

using namespace std;

#define rall(s) s.rbegin(), s.rend()
#define all(s) s.begin(), s.end()
#define sz(s) (int)s.size()
#define s second 
#define f first 

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

vector<int>  find_subset(int l, int r, vector<int> w) {
    int dp[r + 1], n = sz(w);
    memset(dp, 0, sizeof(dp));
    dp[0] = -1;
    for (int i = 1; i <= n; i++) {
        int x = w[i - 1];
        for (int j = r; j >= x; j--) {
            if (dp[j - x] && !dp[j]) dp[j] = i;
        }
    }
    for (int i = l; i <= r; i++) {
        if (dp[i]) {
            vector<int> res;
            while (i) {
                res.push_back(dp[i] - 1);
                i -= w[dp[i] - 1];
            }
            return res;
        }
    }
    return {};
}
#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...