제출 #51647

#제출 시각아이디문제언어결과실행 시간메모리
51647ernestvwDetecting Molecules (IOI16_molecules)C++11
100 / 100
120 ms33896 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; bool cmp(pair<long long, long long> a, pair<long long, long long> b) { return (a.first == b.first ? a.second < b.second : a.first < b.first); } vector<int> find_subset(int l, int u, vector<int> w) { vector<pair<long long, int>> W; vector<int> V; int n = (int)w.size(); for(int i = 0; i < n; i++) W.push_back({w[i], i}); sort(W.begin(), W.end(), cmp); long long mini = 0, maxi = 0; int I = 0; for(int i = 0; i < n; i++, I++) { mini += W[i].first; maxi += W[n - 1 - i].first; if((l <= maxi and maxi <= u) or (l <= mini and mini <= u) or (mini <= l and u <= maxi)) break; } if(I == n) return V; int j = 0; for(j = 0; j <= I; j++) V.push_back(j); while(mini < l) { if(V[I] == n - (j - I)) I--; mini -= W[V[I]].first; V[I] = n - (j - I); mini += W[V[I]].first; } for(int i = 0; i < (int)V.size(); i++) V[i] = W[V[i]].second; return V; }
#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...