# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
138955 | SirCeness | Detecting Molecules (IOI16_molecules) | C++14 | 2 ms | 256 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>
#define pb push_back
#define mp make_pair
#define inside sl<=l&&r<=sr
#define outside r<sl||sr<l
#define orta ((l+r)>>1)
#define INF 1000000009
#define mod 1000000007
#define ppair(x); cerr << "(" << x.first << ", " << x.second << ")\n";
#define bas(x) #x << ": " << x << " "
#define prarr(x, n); cerr << #x << ": "; for(int qsd = 0; qsd < n; qsd++) cerr << x[qsd] << " "; cerr << "\n";
#define prarrv(x); cerr << #x << ": "; for(int qsd = 0; qsd < (int)x.size(); qsd++) cerr << x[qsd] << " "; cerr << "\n";
using namespace std;
typedef long long ll;
vector<int> find_subset(int l, int u, vector<int> w) {
int anssize = -1;
ll pre = 0, suf = 0;
ll top = 0;
sort(w.begin(), w.end());
for (int i = 0; i < w.size(); i++){
pre += w[i];
suf += w[w.size()-i-1];
// cout << bas(i) << bas(pre) << bas(suf) << endl;
if (pre <= u && l <= suf){
anssize = i+1;
top = pre;
break;
}
}
vector<int> ans(0);
if (anssize == -1) return ans;
ans.resize(anssize);
for (int i = 0; i < ans.size(); i++) ans[i] = w[i];
int ind = 0;
while (top < l){
ans[ind] = w[w.size()-ind-1];
top += w[w.size()-ind-1] - w[ind];
ind++;
}
return ans;
}
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... |