이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
vector <int> find_subset(int l,int u,vector<int> a){
vector <pair<int,int>> w;
int n=(int)a.size();
vector<int> ans;
int sum=0;
int r=0;
for(int i=0;i<n;i++)w.push_back({a[i],i});
sort(w.begin(),w.end());
for(int i=0;i<n;i++){
while(sum<l && r<n){
sum+=w[r].first;
r++;
}
if(l<=sum && sum<=u && w[r-1].first-w[i].first<=u-l ){
for(int j=i;j<r;j++){
ans.push_back(w[j].second);
}
return ans;
}
sum-=w[i].first;
}
return {};
}
/*
---------------------------------------------------go get gold---------------------------------------------------------------------
- If u see the problem dp there's many option to iterate, u can iterate from 1- n or 1 - (possible max number)
- If u see the problem that has unexpected constraint u can divide it into 2 problem
- If u see the problem that can use binary search, then u can use binser + check condition
- in interactive problem there's many trick using binser
- kalo misal mau cari yang sama pake pernah ke visit ga bilangan itu
- kalo problem yang high itu biasanya optimisasi nya pake 2 array
- dp bisa aja kek kamu tenzing balls dimana optimisasi 2 dp
- janlup fibonacci
- kalo binser mending r = 3 * 1e18 aja
- kalo mau dibalik itu pake value nya tinggal diubah ke size
*/
# | 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... |