제출 #758570

#제출 시각아이디문제언어결과실행 시간메모리
758570JellyTheOctopusDetecting Molecules (IOI16_molecules)C++17
0 / 100
1 ms212 KiB
// IOI 2016 Day 1 Problem 1 // Detecting Molecules // https://oj.uz/problem/view/IOI16_molecules #include <bits/stdc++.h> using namespace std; #define f first #define s second vector<int> find_subset(int l, int u, vector<int> w) { int N = (int)w.size(); vector<pair<int, int>> valWeight(N); for (int i = 0; i < N; i++) { valWeight[i] = {w[i], i+1}; } sort(valWeight.begin(), valWeight.end()); deque<int> dq; long long curSum = 0; int i = 0; while (i < N) { if (l <= curSum && curSum <= u) { break; } if (curSum < l) { curSum += valWeight[i].f; dq.push_back(i); i++; continue; } if (curSum > u) { curSum -= valWeight[dq.front()].f; dq.pop_front(); } } vector<int> ans; while (!dq.empty() && (l <= curSum && curSum <= u)) { ans.push_back(valWeight[dq.front()].s); dq.pop_front(); } 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...