# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1021226 | vjudge1 | Detecting Molecules (IOI16_molecules) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// #pragma once
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
ll a[200100];
ll sum(int l, int r){
return a[r] - a[l-1];
}
std::vector<int> find_subset(ll L, ll R, std::vector<int> w){
n = w.size();
for(int i = 0; i < n; i++){
a[i+1] = w[i];
}
sort(a + 1, a + n + 1);
for(int i = 1; i <= n; i++){
a[i] += a[i-1];
}
for(int k = 1; k <= n; k++){
if(max(L, sum(1, k)) <= min(R, sum(n - k + 1, n))){
int i = 1;
while(sum(i, i + k - 1) < L || sum(i, i + k - 1) > R){
i++;
}
multiset<int> s;
for(int j = i; j < i + k; j++){
s.insert(a[j] - a[j-1]);
}
vector<int> res;
for(int i = 0; i < n; i++){
if(s.count(w[i])){
s.erase(s.find(w[i]));
res.push_back(i);
}
}
return res;
}
}
return {};
}