이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/*
Zadanie: Detecting Molecules
Autor: Tomasz Kwiatkowski
*/
#include <bits/stdc++.h>
#include "molecules.h"
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
const int MAXN = 1e6 + 7;
const int INF = 1e9 + 7;
vector<int> find_subset(int l, int u, vector<int> w) {
int n = w.size();
vector<pair<int, int>> molecules(n);
for (int i = 0; i < n; ++i)
molecules[i] = {w[i], i};
sort(molecules.begin(), molecules.end());
vector<int> ans;
int r = 0;
ll sum = 0;
for (int left = 0; left < n; ++left) {
while (r < n && sum + molecules[r].fi <= u) {
sum += molecules[r].fi;
if (l <= sum) {
for (int i = left; i <= r; ++i)
ans.pb(molecules[i].se);
return ans;
}
++r;
}
sum -= molecules[left].fi;
r = max(r, left + 1);
}
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... |