# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1223226 | 12baater | Detecting Molecules (IOI16_molecules) | C++20 | 1098 ms | 328 KiB |
#include "molecules.h"
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
struct number {
int n;
int index;
bool operator<(const number& other) const {
return n < other.n;
}
};
vector<int> find_subset(int l, int u, vector<int> w) {
int n = w.size();
vector<number> numbers;
vector<int> ans;
int total = 0;
for (int i = 0; i < w.size(); i++) {
number num;
num.n = w[i];
num.index = i;
numbers.push_back(num);
}
sort(numbers.begin(),numbers.end());
int bigCount = 0, smallCount = 0;
int big = numbers[n-1].n, small = numbers[0].n;
for (auto [num, ind] : numbers) {
if (num == big) bigCount++;
if (num == small) smallCount++;
}
queue<int> ans1;
vector<int> ans2;
for(int i = 0; i < n; i++) {
ans.push_back(numbers[i].index);
total += numbers[i].n;
if (l <= total && total <= u) {
return ans;
}
}
if (total < l) return vector<int>(0);
int i = n-1;
total = 0;
ans.clear();
while (total <= u) {
total += numbers[i].n;
ans1.push(numbers[i].index);
if (total >= l && total <= u) {
while(!ans1.empty()) {
ans.push_back(ans1.front());
ans1.pop();
}
return ans;
}
i--;
}
int lower = 0;
while (lower < n) {
if(ans1.size() > 0) {
total -= w[ans1.front()];
ans1.pop();
}
while (total < l && lower < n) {
ans2.push_back(numbers[lower].index);
total += numbers[lower].n;
lower++;
if (total >= l && total <= u) {
while(!ans1.empty()) {
ans2.push_back(ans1.front());
ans1.pop();
}
return ans2;
}
}
}
return vector<int>(0);
}
컴파일 시 표준 에러 (stderr) 메시지
# | 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... |