이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// IOI 2016 Day 1 Problem 1
// Detecting Molecules
// https://oj.uz/problem/view/IOI16_molecules
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
vector<int> find_subset(int l, int u, vector<int> w) {
int N = (int)w.size();
vector<pair<int, int>> valWeight(N);
for (int i = 0; i < N; i++) {
valWeight[i] = {w[i]*1LL, i};
}
sort(valWeight.begin(), valWeight.end());
deque<int> dq;
long long curSum = 0;
int i = 0;
while (i < N) {
if (l <= curSum && curSum <= u) {
break;
}
if (curSum > u) {
curSum -= valWeight[dq.front()].f;
dq.pop_front();
continue;
}
if (curSum < l) {
curSum += valWeight[i].f;
dq.push_back(i);
i++;
}
}
vector<int> ans;
while (!dq.empty()) {
ans.push_back(valWeight[dq.front()].s);
dq.pop_front();
}
sort(ans.begin(), ans.end());
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... |