제출 #939481

#제출 시각아이디문제언어결과실행 시간메모리
939481ifateenDetecting Molecules (IOI16_molecules)C++14
0 / 100
1 ms600 KiB
#include <bits/stdc++.h> #include "molecules.h" using namespace std; vector<int> find_subset(int l, int u, std::vector<int> w) { vector<int> ans; vector<long long> pref(w.size()); vector<pair<int, int>> arr(w.size()); for (size_t i = 0; i < w.size(); i++) { arr[i] = {w[i], i}; } sort(begin(arr), end(arr)); int len = -1; pref[0] = arr[0].first; for (size_t i = 1; i < w.size(); i++) pref[i] = pref[i - 1] + arr[i].first; for (size_t i = 0; i < w.size(); i++) if (pref[i] > u) { len = i; break; } if (len == -1) { ans.resize(w.size()); iota(begin(ans), end(ans), 0); return ans; } for (size_t i = 0; i < w.size() - len; i++) if (l <= pref[i + len] - pref[i] && pref[i + len] - pref[i] <= u) { for (size_t j = i + 1; j <= i + len; j++) ans.push_back(arr[j].second); return ans; } if (l <= pref[len - 1] && pref[len - 1] <= u) { for (size_t j = 0; j < len; j++) ans.push_back(arr[j].second); } return ans; }

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

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:33:30: warning: comparison of integer expressions of different signedness: 'size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   33 |         for (size_t j = 0; j < len; j++) ans.push_back(arr[j].second);
      |                            ~~^~~~~
#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...