# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
958954 | IUA_Hasin | Detecting Molecules (IOI16_molecules) | C++17 | 1 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 <bits/stdc++.h>
#define endl "\n"
#define yeap cout<<"YES"<<endl
#define nope cout<<"NO"<<endl
#define ll long long
using namespace std;
#include "molecules.h"
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
vector<pair<ll, ll>> v;
for(int i=0; i<w.size(); i++){
ll a = w[i];
v.push_back({a, i});
}
cout<<1<<endl;
cout<<1<<endl;
sort(v.begin(), v.end());
ll s = w.size();
ll arr[s+1];
arr[0] = 0;
for(int i=0; i<s; i++){
ll a = v[i].first;
arr[i+1] = arr[i]+a;
}
ll status = -1;
ll q, r, k;
for(int i=0; i<s; i++){
if(status==1){
break;
} else {
ll a = arr[i+1]-arr[0];
ll b = arr[s]-arr[s-i];
if(a<=u && b>=l){
ll aa = a;
ll bb = 0;
ll cnt = 0;
q = 0;
r = s-1;
cout << aa << " " << bb << " " << i << endl;
while(q<r || cnt<i+1){
if((aa+bb)>=l && (aa+bb)<=u){
status = 1;
k = i+1;
break;
} else {
ll c = w[q];
ll d = w[r];
aa = aa-c;
bb = bb+d;
q++;
r--;
cnt++;
}
}
}
}
}
if(status==-1){
return std::vector<int>(0);
} else {
vector<int> ans;
k--;
for(int i=q; i<=k; i++){
ans.push_back(v[i].second);
}
for(int i=s-1; i>=r; i--){
ans.push_back(v[i].second);
}
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... |