이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define x first
#define y second
#define all(x) x.begin(), x.end()
#define el "\n"
#define pb push_back
#define pp pop_back
#define pii pair <int, int>
#define pll pair <ll, ll>
#define ibase ios_base::sync_with_stdio(0), cin.tie(0);
const int N = 5e5 + 5, M = 1e3 + 5, pw = 31;
const ll MAX = 1e15, inf = 1e9 + 7;
vector <int> find_subset(int l, int u, vector <int> a) {
int n = a.size();
pair <int, int> p[n];
for (int i = 0; i < n; i++) {
p[i] = {a[i], i};
}
sort(p, p + n);
ll sum = 0, j = 0, last = 0;
for (int i = 0; i < n; i++) {
sum += p[i].x;
last = i;
if (sum >= l && sum <= u) {
break;
}
else if (sum >= l) {
j = 0;
while (sum > u)
sum -= p[j++].x;
break;
}
}
if (l > sum || sum > u)
return {};
vector <int> ans;
for (int i = j; i <= last; i++)
ans.pb(p[i].y);
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... |