제출 #1072268

#제출 시각아이디문제언어결과실행 시간메모리
1072268andrewpDetecting Molecules (IOI16_molecules)C++14
100 / 100
58 ms6352 KiB
//#include "molecules.h" //Dedicated to my love, ivaziva #include <bits/stdc++.h> using namespace std; using pii = pair<int, int>; using ll = int64_t; #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define dbg(x) cerr << #x << ": " << x << '\n'; vector<int> find_subset(int l, int u, vector<int> w) { vector<pii> a; for (int i = 0; i < w.size(); i++) { a.push_back({w[i], i}); } sort(all(a)); ll sum = a[0].first; int i = 0, j = 0; vector<int> ans; while (i < a.size() && j < a.size()) { if (sum >= l && sum <= u) { for (int k = i; k <= j; k++) { ans.push_back(a[k].second); } return ans; } if (sum <= u && j < a.size() - 1) { if (j == a.size() - 1) { break; } sum += a[++j].first; } else { sum -= a[i++].first; } } return ans; } /*int32_t main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cerr.tie(nullptr); vector<int> ans = find_subset(14, 15, {5, 5, 6, 6}); for (int x: ans) { cout << x << ' '; } cout << '\n'; return 0; }*/

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

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:15:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |     for (int i = 0; i < w.size(); i++) {
      |                     ~~^~~~~~~~~~
molecules.cpp:22:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |     while (i < a.size() && j < a.size()) {
      |            ~~^~~~~~~~~~
molecules.cpp:22:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |     while (i < a.size() && j < a.size()) {
      |                            ~~^~~~~~~~~~
molecules.cpp:29:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |         if (sum <= u && j < a.size() - 1) {
      |                         ~~^~~~~~~~~~~~~~
molecules.cpp:30:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |             if (j == a.size() - 1) {
      |                 ~~^~~~~~~~~~~~~~~
#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...