제출 #872940

#제출 시각아이디문제언어결과실행 시간메모리
872940karimovDetecting Molecules (IOI16_molecules)C++17
9 / 100
1 ms500 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back vector<int> find_subset(int l, int u, vector<int> w) { int n = w.size(); vector<pair<int,int>> arr(n); for(int i = 0; i < n; i++) { arr[i] = make_pair(w[i],i); } sort(arr.begin(),arr.end()); vector<long long> pref(n+1); for(int i = 1; i <= n; i++) { pref[i] = pref[i-1]+arr[i-1].first; // cout <<i << " " << pref[i] << endl; } // cout<<endl; vector<int>ans; int left = 1, right = n; while(left<=right) { int x = pref[right]-pref[left-1]; // cout << left << " " << right << " " << x << endl; if(x >= l && x <= u) { for(int i = left-1; i < right; i++) { ans.pb(arr[i].second); } break; } if(x > l) { left++; } else { right--; } } return ans; }
#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...