이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "molecules.h"
#define maxn (int)(1e5+51)
#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define endl '\n'
#define ll long long
#define pb push_back
#define ull unsigned long long
#define ii pair<int,int>
#define iii tuple<int,int,int>
#define inf 2000000001
#define mod 1000000007 //998244353
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
template<typename X, typename Y> bool ckmin(X& x, const Y& y) { return (y < x) ? (x=y,1):0; }
template<typename X, typename Y> bool ckmax(X& x, const Y& y) { return (x < y) ? (x=y,1):0; }
int dp[20005],pos[10001];
vector<int>where[10001];
vector<int> find_subset(int l, int u, vector<int> w) {
for(int i=0;i<20005;i++)dp[i]=-1;
int i=0;
dp[0] = 0;
vector<int>can,aux;can.pb(0);
for(auto x:w){
where[x].pb(i++);
for(auto y:can){
if(x+y<=u&&dp[x+y]==-1){
aux.pb(x+y);
dp[x+y] = y;
}
}
for(auto z:aux)can.pb(z);
aux.clear();
}
vector<int>ans;
for(int i=l;i<=u;i++){
if(dp[i]!=-1){
while(i){
ans.pb(i-dp[i]);
i=dp[i];
}
break;
}
}
for(auto& x:ans)x = where[x][pos[x]++];
return ans;
}
// int main(){
// int l,u,n;cin>>l>>u>>n;
// vector<int>w;
// for(int i=0;i<n;++i){
// int x;cin>>x;w.pb(x);
// }
// vector<int>resp = find_subset(l,u,w);
// if(!sz(resp))cout<<-1;
// else for(auto x:resp)cout<<x<<" ";
// cout<<endl;
// }
# | 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... |