# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
972449 | vjudge1 | Detecting Molecules (IOI16_molecules) | C++11 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "molecules.h"
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define double long double
#define pon ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); int T=1;
#define ponchik signed main
#define pb push_back
#define pf push_front
#define endl "\n"
#define F first
#define S second
const long long N=1e5+69,INF=1e18+1488;
vector<int> find_subset(int l, int u, vector<int> w)
//int main()
{
long long n=w.size(),a=l,b=u;
vector <pair<long long,long long>> w1;
// vector <long long> w;
// for (int i=0; i<n; i++)
// {
// int x; cin>>x;
// w.pb(x);
// }
for (int i=0; i<n; i++)
{
// int x; cin>>x;
int x=w[i];
w1.pb({x,i});
}
sort(w1.begin(),w1.end());
long long l1=0,r=0,sum=w[0];
vector <int> ans;
while (l1<=r&&l1<n)
{
if (sum>=a&&sum<=b)
{
for (int i=l1; i<=r; i++) ans.pb(w1[i].S);
break;
}
if (sum<a) r++,sum+=w1[r].F;
else if (sum>b) l1++,sum-=w[l1-1].F;
}
return ans;
}