# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
240232 | Dremix10 | Detecting Molecules (IOI16_molecules) | C++17 | 145 ms | 65540 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "molecules.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define F first
#define S second
//#define endl '\n'
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define maxp 22
#define EPS (ld)(1e-18)
#define mod (int)(1e9+7)
#define N (int)(1e5+1)
bool dp[10001][10001];
vector<int> find_subset(int l, int r, vector<int> arr) {
int n=arr.size();
int i,j;
dp[0][0]=true;
for(i=1;i<=n;i++)
for(j=0;j<=10001;j++){
dp[i][j]|=dp[i-1][j];
if(j>=arr[i-1])
dp[i][j]|=dp[i-1][j-arr[i-1]];
}
int k;
for(k=l;k<=r;k++)
if(dp[n][k]){
//cout<<n<<" "<<k<<endl;
vector<int> ans;
int num=k;
int row=n;
while(num>0){
for(i=row;i>0;i--)
if(num>=arr[i-1])
if(dp[i-1][num-arr[i-1]]){
row=i-1;
num-=arr[i-1];
ans.push_back(i-1);
break;
}
}
return ans;
}
return vector<int>(0);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |