제출 #763890

#제출 시각아이디문제언어결과실행 시간메모리
763890ind1vDetecting Molecules (IOI16_molecules)C++11
0 / 100
1 ms340 KiB
#include <bits/stdc++.h> using namespace std; vector<int> find_subset(int l, int u, vector<int> w) { int n = w.size(); vector<int> ord(n); iota(ord.begin(), ord.end(), 0); sort(ord.begin(), ord.end(), [&w](int &i, int &j) -> bool { return w[i] < w[j]; }); deque<int> dq; long long sum = 0; for (int i = 0; i < n; i++) { if (sum + w[ord[i]] < l) { dq.emplace_back(ord[i]); sum += w[ord[i]]; } else if (l <= sum + w[ord[i]] && sum + w[ord[i]] <= u) { dq.emplace_back(ord[i]); sum += w[ord[i]]; vector<int> ans(dq.begin(), dq.end()); return ans; } else { if (dq.empty()) { return vector<int>(0); } else { sum -= w[dq.front()]; dq.pop_front(); sum += w[ord[i]]; dq.push_back(ord[i]); if (l <= sum && sum <= u) { vector<int> ans(dq.begin(), dq.end()); return ans; } } } } }

컴파일 시 표준 에러 (stderr) 메시지

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:7:20: warning: control reaches end of non-void function [-Wreturn-type]
    7 |   vector<int> ord(n);
      |                    ^
#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...