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 F first
#define S second
#define V vector
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(v) int((v).size())
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;
const int INF = 1e9 + 7;
vi find_subset(int l, int r, vi w) {
V<pi> tt;
for(int i = 0; i < SZ(w); i++)
tt.EB(w[i], i);
sort(ALL(tt), greater<pi>());
vi ans;
ll sum = 0;
for(int i = 0; i < SZ(w); i++) {
sum += tt[i].F;
if(l <= sum && sum <= r) {
for(int j = 0; j <= i; j++)
ans.PB(tt[j].S);
break;
}
}
if(ans.empty()) {
sort(ALL(tt), less<pi>());
ll sum = 0;
for(int i = 0; i < SZ(w); i++) {
sum += tt[i].F;
if(l <= sum && sum <= r) {
for(int j = 0; j <= i; j++)
ans.PB(tt[j].S);
break;
}
}
}
sort(ALL(ans));
return ans;
}
# | 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... |