# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
624285 | Vovamatrix | Detecting Molecules (IOI16_molecules) | C++14 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//https://oj.uz/problem/view/IOI16_molecules
#include "molecules.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define sc second
#define th third
#define fo fourth
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ldb double
#define endl "\n"
#define all(data) data.begin(),data.end()
#define TYPEMAX(type) std::numeric_limits<type>::max()
#define TYPEMIN(type) std::numeric_limits<type>::min()
#define MAXN 200007
ll w[MAXN];
ll prefsum[MAXN];
vector<ll> sol(ll l, ll u, vector<ll> w)
{
ll n=w.size();
sort(all(w));
prefsum[0]=0;
for(int i=1;i<=n;i++) prefsum[i]=prefsum[i-1]+w[i-1];
ll itr1=0,itr2=1;
vector<ll> v;
while(itr2<=n)
{
if(prefsum[itr2]-prefsum[itr1]>u) itr1++;
else if(prefsum[itr2]-prefsum[itr1]<l) itr2++;
else
{
for(int i=itr1+1;i<=itr2;i++) v.pb(w[i]);
break;
}
}
return v;
}