제출 #209102

#제출 시각아이디문제언어결과실행 시간메모리
209102my99nDetecting Molecules (IOI16_molecules)C++14
9 / 100
6 ms380 KiB
#include<bits/stdc++.h> using namespace std; #include "molecules.h" vector<int> find_subset(int l, int u, vector<int> w) { vector<int> ans; vector<pair<int,int>> s; for (int i = 0; i < w.size(); i++) s.push_back({w[i], i}); sort(s.begin(), s.end()); int wmax = (s.end()-1)->first, wmin = s.begin()->first; if (wmin > u) return vector<int>(0); if (l <= wmin and wmin <= u) return vector<int>(1, s[0].second); if (l <= wmax and wmax <= u) return vector<int>(1, s.back().second); reverse(s.begin(), s.end()); int val = 0; for (int i = 0; i < s.size(); i++) { ans.push_back(s[i].second); val += s[i].first; if (val < l) continue; if (l <= val and val <= u) return ans; if (u < val) { ans.pop_back(); val -= w[i]; continue; } } return vector<int>(0); }

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

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:8:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < w.size(); i++) s.push_back({w[i], i});
                     ~~^~~~~~~~~~
molecules.cpp:17:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < s.size(); i++) {
                     ~~^~~~~~~~~~
#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...