# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
199390 | kshitij_sodani | Detecting Molecules (IOI16_molecules) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <bits/stdc++.h>
#include "molecules.h"
using namespace std;
typedef long long int llo ;
#define mp make_pair
#define pb push_back
#define a first
#define b second
vector<llo> find_subset(llo l,llo u,vector<llo> w){
llo dp[1001];
memset(dp,0,sizeof(dp));
dp[0]=1;
for(llo j=0;j<w.size();j++){
for(llo i=1001;i>=w[j];i--){
if(dp[i-w[j]]!=0 and dp[i]==0){
dp[i]=j+1;
}
}
}
llo ind=-1;
for(llo i=l;i<u+1;i++){
if(dp[i]>0){
ind=i;
break;
}
}
//cout<<ind<<endl;
//cout<<w[dp[15]]<<endl;
vector<llo> ans;
if(ind==-1){
return ans;
}
while(ind>0){
ans.pb(dp[ind]);
ind-=w[dp[ind]-1];
}
return ans;
}
/*
int main(){
vector<llo> ss=find_subset(15,17,{6,8,8,7});
for(int i=0;i<ss.size();i++){
cout<<ss[i]<<" ";
}
cout<<endl;
return 0;
}*/