제출 #380154

#제출 시각아이디문제언어결과실행 시간메모리
380154vishesh312Detecting Molecules (IOI16_molecules)C++17
0 / 100
1 ms492 KiB
#include"molecules.h" #include"bits/stdc++.h" using namespace std; using ll = long long; vector<int> find_subset(int l, int u, vector<int> w) { vector<pair<ll, int>> v; for (int i = 0; i < (int)w.size(); ++i) { v.push_back({w[i], i}); } int n = w.size(); sort(v.begin(), v.end()); ll sum = 0; vector<int> pre, suf; for (int i = 0; i < n; ++i) { if (sum + v[i].first > u) { break; } sum += v[i].first; pre.push_back(v[i].second); } if (sum >= l) { return pre; } for (int i = n-1; i >= 0; --i) { if (pre.size() + suf.size() == n or pre.size() == suf.size()) { break; } suf.push_back(v[i].second); } deque<int> dq(pre.begin(), pre.end()); for (int i = 0; i < (int)pre.size(); ++i) { sum -= w[pre[i]]; sum += w[suf[i]]; dq.pop_front(); dq.push_back(suf[i]); if (sum >= l and sum <= u) { vector<int> ret(dq.begin(), dq.end()); return ret; } } vector<int> ret; return ret; } /* int main() { int l, r, n; cin >> l >> r >> n; vector<int> v(n); for (auto &x : v) cin >> x; v = find_subset(l, r, v); for (auto x : v) cout << x << " "; } */

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

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:26:37: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   26 |         if (pre.size() + suf.size() == n or pre.size() == suf.size()) {
      |             ~~~~~~~~~~~~~~~~~~~~~~~~^~~~
#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...