제출 #392186

#제출 시각아이디문제언어결과실행 시간메모리
392186HegdahlDetecting Molecules (IOI16_molecules)C++17
19 / 100
1 ms208 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) { ll l = _l, u = _u; int n = w.size(); ll mn = 1LL<<60; for (int v : w) mn = min(mn, (ll)v); if (mn > u) return {}; vector<int> idxs(n); iota(idxs.begin(), idxs.end(), 0); sort(idxs.begin(), idxs.end(), [&](int i, int j){ return w[i] < w[j]; }); ll s = 0; vector<int> ans; for (int _i = 0; _i < n; ++_i) { int i = idxs[_i]; if (s + w[i] > u) { break; } s += w[i]; ans.push_back(i); if (s >= l) return ans; } int i = 0; int d = n-ans.size(); while (i+d < n && i < ans.size()) { s -= w[ans[i]]; ans[i] = idxs[i+d]; s += w[ans[i]]; ++i; if (s >= l) return ans; } return {}; }

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

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:41:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |   while (i+d < n && i < ans.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...