제출 #1105885

#제출 시각아이디문제언어결과실행 시간메모리
1105885abushbandit_Detecting Molecules (IOI16_molecules)C++17
69 / 100
53 ms6596 KiB
#include "molecules.h" #include "bits/stdc++.h" using namespace std; vector<int> find_subset(int a, int b, vector<int> w) { vector<pair<int,int>> w2; int j = 1; for(auto i : w) w2.push_back({i,j++}); sort(w.begin(),w.end()); sort(w2.begin(),w2.end()); int n = w.size(); int resr = 0,resl = n; int l = 0; int ans = 0; int sum = 0; for(int r = 0;r < n;r++) { sum += w[r]; if(sum < a) { continue; } while(sum > b && l <= r) { sum -= w[l]; l++; } if(sum >= a && sum <= b) { if(ans < r - l + 1) { ans = r - l + 1; resr = r,resl = l; } } } vector<int> res; for(int i = resl;i <= resr;i++) { res.push_back(w2[i].second - 1); } return res; }
#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...