제출 #395115

#제출 시각아이디문제언어결과실행 시간메모리
395115jeroenodbDetecting Molecules (IOI16_molecules)C++14
0 / 100
1 ms208 KiB
#include "molecules.h" #include "bits/stdc++.h" using namespace std; #define all(x) begin(x),end(x) template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; } template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { string sep; for (const T &x : v) os << sep << x, sep = " "; return os; } #define debug(a) cerr << "(" << #a << ": " << a << ")\n"; typedef long long ll; typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int,int> pi; struct we{ int w, id; bool operator<(const we& o) { return w<o.w; } }; std::vector<int> find_subset(int l, int u, std::vector<int> w) { int n = w.size(); vector<we> mw; mw.reserve(n); for(int i=0;i<n;++i) mw.push_back({w[i],i}); sort(mw.begin(),mw.end()); ll sum =0; for(int i=0,j=0;i<n;++i) { while(j<n and sum+mw[j].w<=u) { ++j; sum+=mw[j].w; } if(l<=sum and sum<=u) { vi ans; for(int p = i;p<j;++p) { ans.push_back(mw[p].id); } return ans; } sum-=mw[i].w; } 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...