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"
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#define M_PI 3.14159265358979323846
#define FILER 0
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const ll MOD = pow(10, 9) + 7;
const ll INFL = 0x3f3f3f3f3f3f3f3f;
const ull INFUL = 0x3f3f3f3f3f3f3f3f;
const ll INFT = 0x3f3f3f3f;
const ull MAX = 1LL << 24;
const ll MODD = 998244353;
const double EPS = 1e-10;
#define V vector
#define pll pair<ll, ll>
#define pull2 pair<ull,ull>
#define MS multiset
#define M map
#define Q queue
#define PQ priority_queue
#define IOF ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define FOR(typ,i,a,b,c) for(typ i = a; i < b; i += c)
#define FORR(typ,i,a,b,c) for(typ i = a; i > b; i -= c)
#define FORA(a,i) for(auto &i : a)
#define all(v) v.begin(),v.end()
#define sz(v) v.size()
#define sorta(a) sort(all(a))
#define sortd(a) sort(all(a), greater<ll>())
#define setp(x) setprecision(x)<<fixed
#define RET return
#define log(a,b) log(b)/log(a)
#define WH(s) while(s)
#define WHI(t) WH(t--)
#define YES cout<<"YES"<<endl;
#define NO cout<<"NO"<<endl;
#define Yes cout<<"Yes"<<endl;
#define No cout<<"No"<<endl;
#define YESNO(s) cout << (s ? "YES" : "NO") << endl;
#define YesNo(s) cout<<(s?"Yes":"No")<<endl;
#define TYP
#define F first
#define S second
#define pb push_back
using namespace std;
std::vector<int> find_subset(int l, int u, std::vector<int> w)
{
int n = w.size();
pair<int,int> a[n + 7];
int sum = 0;
for (int i = 1; i <= n; i++) {
a[i] = {w[i - 1], i};
sum += a[i].F;
}
sort (a + 1, a + n + 1);
if (sum < l) {
return {};
}
int r = u;
if (a[1].F > u) {
return vector<int>(0);
}
int cur = 0;
vector<int> result;
for (int i = 1; i <= n; i++) {
if (cur + a[i].F >= l) {
if (cur + a[i].F <= r) {
cur += a[i].F;
result.pb(a[i].S);
}
break;
}
cur += a[i].F;
result.pb(a[i].S);
}
if (cur < l) {
for (int i = 0; i < (int)result.size(); i++) {
if (cur - a[i + 1].F + a[n].F <= r) {
result[i] = a[n].S;
break;
}
}
}
if (cur >= l && cur <= r) {
return result;
}
return vector<int> (0);
}
# | 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... |