이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "molecules.h"
#include <memory.h>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <vector>
#define maxx 200005
using namespace std;
typedef long long ll;
struct data{
ll w;
int idx;
};
data p[maxx];
bool cmp(data a, data b){
return a.w < b.w;
}
std::vector<int> find_subset(int l, int u, std::vector<int> weight){
vector<int>res;
res.clear();
int n = weight.size();
for(int i = 0; i < n; i++){
p[i].w = 1LL * weight[i];
p[i].idx = i;
}
sort(p, p + n, cmp);
ll sum = 0;
int ptr1 = 0, ptr2 = 0;
while(ptr1 < n){
while(ptr2 < n && sum < 1LL * l){
sum += p[ptr2].w;
ptr2++;
}
if(sum >= 1LL * l && sum <= 1LL * u){
for(int i = ptr1; i < ptr2; i++){
res.push_back(p[i].idx);
}
return res;
}
else{
while(ptr1 < n && sum > 1LL * u){
sum -= p[ptr1].w;
ptr1++;
}
}
if(ptr2 == n && sum < 1LL * l)
break;
}
return res;
}
| # | 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... |