# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
138958 | SirCeness | Detecting Molecules (IOI16_molecules) | C++14 | 67 ms | 7336 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) {
vector<pair<ll, int> > arr(w.size());
for (int i = 0; i < w.size(); i++){
arr[i] = mp(w[i], i);
}
int anssize = -1;
ll pre = 0, suf = 0;
ll top = 0;
sort(arr.begin(), arr.end());
for (int i = 0; i < w.size(); i++){
pre += arr[i].first;
suf += arr[arr.size()-i-1].first;
// 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] = arr[i].second;
int ind = 0;
while (top < l){
ans[ind] = arr[arr.size()-ind-1].second;
top += arr[arr.size()-ind-1].first - arr[ind].first;
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... |