제출 #388548

#제출 시각아이디문제언어결과실행 시간메모리
388548alireza_kavianiDetecting Molecules (IOI16_molecules)C++11
0 / 100
1 ms204 KiB
#include <bits/stdc++.h> #include "molecules.h" using namespace std; typedef long long ll; typedef pair<int , int> pii; #define X first #define Y second #define sep ' ' #define all(x) (x).begin() , (x).end() #define SZ(x) int(x.size()) vector<int> find_subset(int l, int u, vector<int> w) { vector<pii> vec; vector<int> ans1 , ans2; int n = SZ(w) ; ll sum = 0; for(int i = 0 ; i < n ; i++){ vec.push_back({w[i] , i}); } sort(all(vec)); for(pii i : vec){ sum += i.X; ans1.push_back(i.Y); if(sum >= l) break; } if(sum <= u){ sort(all(ans1)); return ans1; } sum -= w[ans1.back()]; ans1.pop_back(); while(SZ(ans1)){ sum -= w[ans1.back()]; ans1.pop_back(); n--; sum += w[vec[n].Y]; ans2.push_back(vec[n].Y); if(l <= sum){ for(int i : ans2) ans1.push_back(i); sort(all(ans1)); return ans1; } } return vector<int>(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...