# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1008898 | jer033 | Detecting Molecules (IOI16_molecules) | C++17 | 39 ms | 10368 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "molecules.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pli = pair<long long, int>;
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
int molecule_count = w.size();
vector<pli> molecules;
molecules.reserve(molecule_count);
for (int i=0; i<molecule_count; i++)
{
molecules.push_back({w[i], i});
}
sort(molecules.begin(), molecules.end());
ll lower_bound = l;
ll upper_bound = u;
vector<ll> prefix_sums;
vector<ll> suffix_sums;
prefix_sums.reserve(molecule_count+1);
suffix_sums.reserve(molecule_count+1);
prefix_sums.push_back(0);
for (int i=0; i<molecule_count; i++)
{
prefix_sums.push_back(prefix_sums[i]+molecules[i].first);
}
suffix_sums.push_back(0);
for (int i=0; i<molecule_count; i++)
{
suffix_sums.push_back(suffix_sums[i]+molecules[molecule_count-1-i].first);
}
int ele_count = -1;
for (int i=0; i<=molecule_count; i++)
if ((prefix_sums[i]<=u) and (suffix_sums[i]>=l))
ele_count = i;
if (ele_count == -1)
return {};
vector<int> rearranged_indices;
rearranged_indices.reserve(ele_count+1);
for (int i=0; i<ele_count; i++)
rearranged_indices.push_back(i);
ll curr_sum = prefix_sums[ele_count];
int j = 0;
while (curr_sum < l)
{
rearranged_indices[j] = molecule_count-1-j;
curr_sum = curr_sum - molecules[j].first + molecules[molecule_count-1-j].first;
j++;
}
vector<int> ans;
ans.reserve(ele_count+1);
for (int i=0; i<ele_count; i++)
{
ans.push_back(molecules[rearranged_indices[i]].second);
}
return ans;
}
컴파일 시 표준 에러 (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... |