제출 #961267

#제출 시각아이디문제언어결과실행 시간메모리
961267aminjon__Detecting Molecules (IOI16_molecules)C++17
69 / 100
36 ms5576 KiB
#include<bits/stdc++.h> using namespace std; pair<int,int>w2[200012]; vector <int>result; vector<int> find_subset(int l , int r , vector<int> w){ int n = w.size(),sum = 0 , left = 0 , right = 0; for(int i = 0;i < n;i++){ w2[i].first = w[i]; w2[i].second = i; } sort(w2 , w2+n , greater<pair<int,int>>()); while(sum < l && right < n){ sum += w2[right].first; result.push_back(w2[right].second); right++; } if(sum >= l && sum <= r){ return result; } else if(sum < l || right == n){ result.clear(); return result; } int last = n-1; while(last >= right && sum > r && left < right){ sum -= w2[left].first-w2[last].first; result[left] = w2[last].second; last--; left++; } if(sum >= l && sum <= r){ return result; } while(sum > r && result.size()>0){ sum -= w[result.back()]; result.pop_back(); } result.clear(); return result; } // int main(){ // int l , r , x; // cin >>l >> r; // vector <int> in , finale; // while(cin >>x ){ // in.push_back(x); // // } // // finale = find_subset(l , r ,in); // cout<<finale.size()<<'\n'; // for(int i: finale){ // cout<<i<<' '; // } // }
#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...