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 ll long long
#define ull unsigned long long
#define pb(e) push_back(e)
#define sv(a) sort(a.begin(),a.end())
#define sa(a,n) sort(a,a+n)
#define mp(a,b) make_pair(a,b)
#define vf first
#define vs second
#define ar array
#define all(x) x.begin(),x.end()
const int inf = 0x3f3f3f3f;
const int mod = 1000000007;
const double PI=3.14159265358979323846264338327950288419716939937510582097494459230;
bool remender(ll a , ll b){return a%b;}
vector<int> find_subset(int l, int u, vector<int> w){
int n = w.size();
vector<pair<ll,int>> arr;
for(int i = 0; i < n; i++){
arr.pb(mp(w[i] , i));
}
sv(arr);
ll sum = 0;
queue<int> q;
for(int i = 0; i < n; i++){
sum += arr[i].vf;
q.push(i);
while(sum > u){
int pos = q.front();
q.pop();
sum -= arr[pos].vf;
}
if(sum >= l && sum <= u)break;
}
vector<int> v;
while(q.size() && sum >= l && sum <= u){
int pos = q.front();
q.pop();
v.pb(arr[pos].vs);
}
return v;
}
# | 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... |