# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
962698 | hirayuu_oj | Detecting Molecules (IOI16_molecules) | C++17 | 0 ms | 348 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;
#define rep(i,n) for(int i=0; i<n; i++)
#define all(x) x.begin(),x.end()
using ll=long long;
void out(int x){
cerr<<x;
}
void out(ll x){
cerr<<x;
}
template<typename F,typename S>
void out(pair<F,S> x){
cerr<<"(";
out(x.first);
cerr<<", ";
out(x.second);
cerr<<")";
}
template<typename S>
void out(S x){
cerr<<"[";
for(auto i:x){
out(i);
cerr<<", ";
}
cerr<<"]";
}
template<typename H>
void DBG(H x){
cerr<<"DBG:";
out(x);
cerr<<"\n";
}
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
int n=w.size();
vector<ll> cum(w.size()+1,0);
vector<pair<ll,ll>> wi(w.size());
rep(i,w.size()){
wi[i]={w[i],i};
}
sort(all(wi));
rep(i,n){
cum[i+1]=cum[i]+wi[i].first;
}
rep(i,n+1){
if(cum[i]>u)continue;
if(cum[n]-cum[n-i]<l)continue;
rep(j,i+1){
if(l<=cum[j]+cum[n]-cum[n-(i-j)]&&cum[j]+cum[n]-cum[n-(i-j)]<=u){
vector<int> ans(0);
rep(k,j){
ans.push_back(wi[k].second+1);
}
rep(k,i-j){
ans.push_back(wi[n-k-1].second+1);
}
rep(k,j){
assert(1<=ans[k]&&ans[k]<=n);
}
return ans;
}
}
}
return std::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... |