# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
255822 | jainbot27 | Detecting Molecules (IOI16_molecules) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
// #include <molecules.h>
using namespace std;
using ll = long long;
// u - l >= wmax - wmin
// what does this mean for me
vector<int> find_subset(int l, int u, vector<int> w){
vector<int> ret;
vector<pair<int, int>> ww;
int n = w.size();
for(int i =0; i < n; i++){
ww.push_back({w[i], i});
}
sort(ww.begin(), ww.end());
if(ww[0].first >= l && ww[0].first<= u){
ret.push_back(ww[0].second);
return ret;
}
int z = 0;
ll sum = ww[0].first;
for(int i =1; i < n; i++){
sum += ww[i].first;
while(sum > u && z < n){
sum -= ww[z].first;
z++;
}
if(sum >= l && sum <= u){
for(int j = z; j <= i; j++){
ret.push_back(ww[j].second);
}
return ret;
}
}
return ret;
}
int main(){
int l = 15;
int u = 20;
vector<int> w = {7, 8, 12, 12};
vector<int> ret = find_subset(l, u, w);
for(int x : ret){
cout << x << " ";
}
cout << endl;
}