| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 290753 | REALITYNB | Detecting Molecules (IOI16_molecules) | C++14 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define int long long
#define all(a) a.begin(),a.end()
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
using namespace std;
vector<int> find_subset(int l , int r , vector<int> a){
sort(all(a)) ;
int sum= 0 ;
for(int& x :a) sum+= x ;
set<int> ans ;
int n = a.size() ;
for(int i=0;i<n;i++) ans.insert(i) ;
vector<int> re ;
set<pii> b ;
for(int i=0;i<a.size();i++) b.insert(mp(a[i],i)) ;
if(sum<l){
return re ;
}
if(sum<=l&&sum<=r){
for(int x : ans) re.push_back(x) ;
return re ;
}
while(sum>r&&b.size()){
auto it = b.end() ;
it-- ;
pii w = *it ;
if(sum-w.F>r){
sum-=w.F ;
b.erase(it) ;
ans.erase(w.S) ;
}
else if(sum-w.F<l){
b.erase(it) ;
}
else{
b.erase(it) ;
ans.erase(w.S) ;
sum-=w.F ;
break ;
}
}
if(sum>r)
return re ;
// cout << 1 << " " ;
for(int x : ans) re.push_back(x) ;
return re ;
}
