#include <bits/stdc++.h>
#include "molecules.h"
#define TASK "molecules"
#define INT_LIM (int) 2147483647
#define LL_LIM (long long) 9223372036854775807
#define endl '\n'
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define BIT(i,x) (((i)>>(x))&1)
#define FOR(i,a,b) for(int i = (a); i<=(b); i++)
#define FORD(i,a,b) for(int i = (a); i>=(b); i--)
#define ll long long
#define pii pair<int,int>
using namespace std;
///------------------------------------------///
//#define int ll
vector<pair<ll,int>> f;
vector<int> find_subset(int l, int u, vector<int> w)
{
for (int i = 0; i<(int)w.size(); i++)
{
f.pb(mp(w[i], i));
}
sort(f.begin(), f.end());
vector<int> ret;
int j = 0;
ll sum = 0;
for (int i = 0; i<(int)f.size(); i++)
{
ll val = f[i].fi;
sum+=val;
while (j<i && sum>u)
{
sum-=f[j].fi;
j++;
}
if (sum>=l && sum<=u)
{
FOR(t, j, i) ret.pb(f[t].se);
return ret;
}
}
return vector<int>(0);
}
//
//signed main()
//{
// ///--------------------------///
// ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
// if (fopen(TASK".INP","r")!=NULL)
// {
// freopen(TASK".INP","r",stdin);
// freopen(TASK".OUT","w",stdout);
// }
// ///--------------------------///
//
// vector<int> g = find_subset(15, 17, {6, 8, 8, 7});
//
// for (auto i:g) cout << i << ' ';
//
//
// return 0;
//}
//
/////------------------------------------------///
Compilation message (stderr)
molecules.h:1:9: warning: #pragma once in main file
1 | #pragma once
| ^~~~
molecules_c.h:1:9: warning: #pragma once in main file
1 | #pragma once
| ^~~~
# | 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... |