이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define all(fl) fl.begin(),fl.end()
#define pb push_back
#define fi first
#define se second
#define for1(i,j,k) for(int i=j;i<=k;i++)
#define for2(i,j,k) for(int i=j;i>=k;i--)
#define for3(i,j,k,l) for(int i=j;i<=k;i+=l)
#define lb lower_bound
#define ub upper_bound
#define sz(a) (int)a.size()
#define pii pair<int,int>
#define pli pair<long long,int>
#define gcd __gcd
#define lcm(x,y) x*y/__gcd(x,y)
long long f[200009];
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
vector<int>ans;
vector<pii>a;
int n=sz(w);
for1(i,0,n-1)a.pb({w[i],i});
sort(all(a));
if (a[0].fi>u)return {};
for1(i,0,n-1){
if (a[i].fi>=l&&a[i].se<=u){
return {a[i].se};
}
}
int sum=0;
vector<int>id;
for1(i,0,n-1){
f[i+1]=f[i]+a[i].fi;
}
for1(i,1,n){
int l1=1,r1=i,ans=-1;
while (l1<=r1){
int mid=(l1+r1)>>1;
if (f[i]-f[mid-1]>u){
l1=mid+1;
}
else {
r1=mid-1;
ans=mid;
}
}
if (ans!=-1&&f[i]-f[ans-1]>=l){
for1(j,ans,i)id.pb(a[j-1].se);
return id;
}
}
return {};
}
컴파일 시 표준 에러 (stderr) 메시지
molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:30:9: warning: unused variable 'sum' [-Wunused-variable]
30 | int sum=0;
| ^~~
# | 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... |