//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
vector<int> find_subset(int l, int r, vector<int> ve) {
vector<pair<int, int>> w;
for (int i = 0; i < ve.size(); ++i) {
w.push_back({ve[i], i});
}
sort(w.begin(), w.end());
for (int i = 0; i < w.size(); ++i) {
if (w[i].first >= l && w[i].first <= r) {
return {w[i].second + 1};
}
}
long long kek = accumulate(ve.begin(), ve.end(), 0ll);
if (kek >= l && kek <= r) {
vector<int> rs(ve.size());
iota(rs.begin(), rs.end(), 1ll);
return rs;
}
long long sm = w[0].first;
vector<int> ans;
for (int i = 1; i < w.size(); ++i) {
if (sm > r) break;
sm += w[i].first;
if (sm >= l && sm <= r) {
for (int j = 0; j <= i; ++j) {
ans.push_back(w[j].second + 1);
}
return ans;
}
long long xx = sm - w[0].first + w.back().first;
if (xx >= l && xx <= r) {
for (int j = 1; j <= i; ++j) {
ans.push_back(w[j].second + 1);
}
ans.push_back(w.back().second + 1);
return ans;
}
}
return {};
}
/*
signed main() {
auto res = find_subset(14, 15, {5, 5, 6, 6});
cout << res.size() << '\n';
for (auto i : res) {
cout << i << ' ';
}
}*/
컴파일 시 표준 에러 (stderr) 메시지
molecules.h:1:9: warning: #pragma once in main file
1 | #pragma once
| ^~~~
molecules_c.h:1:9: warning: #pragma once in main file
1 | #pragma once
| ^~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |