| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 921331 | H1H | Detecting Molecules (IOI16_molecules) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define T "Task"
using namespace std;
vector<int> find_subset(int l, int u, vector<int> w){
vector<pair<int, int>> a;
for(int i = 0; i < w.size(); ++i){
a.push_back({w[i], i});
}
sort(a.begin(), a.end(), [](pair<int,int> a1, pair<int,int> a2){
return a1.first > a2.first;
});
vector<int> ans;
long long sum_val = 0;
int id = 0;
while(true){
if(id == a.size())break;
sum_val += a[id].first;
ans.push_back(a[id].second);
if(sum_val >= l && sum_val <= u){
return ans;
}
if(sum_val > u){
sum_val -= a[ans[0]].first;
ans[0] = a[a.size()-1].second;
sum_val += a[ans[0]].first;
if(!(sum_val >= l && sum_val <= u) || id == a.size()-1){
ans.clear();
}
return ans;
}
id += 1;
}
ans.clear();
return ans;
}
void ip(){
// vector<int> a = {15, 17, 16, 18};
// for(auto ai : find_subset(10, 20, a)){
// cout << ai << '\n';
// }
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
if(fopen(T".INP", "r")){
freopen(T".INP", "r", stdin);
freopen(T".OUT", "w", stdout);
}
// int tt = 1;
//// cin >> tt;
// while(tt--){
// ip();
// }
}
