제출 #1011987

#제출 시각아이디문제언어결과실행 시간메모리
1011987hotboy2703Detecting Molecules (IOI16_molecules)C++17
19 / 100
1 ms348 KiB
#include "molecules.h" #include<bits/stdc++.h> using namespace std; using ll = long long; #define pll pair <ll,ll> #define fi first #define se second #define MP make_pair #define sz(a) (ll((a).size())) #define BIT(mask,i) (((mask) >> (i))&1) #define MASK(i) (1LL << (i)) std::vector<int> find_subset(int l, int u, std::vector<int> w) { int n = sz(w); vector <int> order(n); iota(order.begin(),order.end(),0); sort(order.begin(),order.end(),[&](ll x,ll y){return w[x] < w[y];}); ll sum_L,sum_R; sum_L=sum_R=0; for (ll i = 0;i < n;i ++){ sum_L += w[order[i]]; sum_R += w[order[n-1-i]]; // cout<<sum_L<<' '<<sum_R<<endl; if (sum_L > u || sum_R < l)continue; vector <int> res; if (l <= sum_L && sum_L <= u){ for (ll j = 0;j <= i;j ++)res.push_back(order[j]); } else if (l <= sum_R && sum_R <= u){ for (ll j = n - i - 1;j < n;j ++)res.push_back(order[j]); } else{ for (ll j = 0;j <= i;j ++)res.push_back(order[j]); ll sum = sum_L; ll last = n; for (ll j = i;j >= 0;j --){ sum += w[order[last - 1]] - w[order[res[j]]]; res[j] = last - 1; if (sum >= l){ while (sum > u){ sum -= w[order[res[j]]] - w[order[res[j]-1]]; res[j]--; } break; } last = res[j]; } } return res; } return std::vector<int>(0); }
#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...