제출 #1118933

#제출 시각아이디문제언어결과실행 시간메모리
1118933adaawfDetecting Molecules (IOI16_molecules)C++17
9 / 100
1 ms596 KiB
#include <iostream> #include <vector> #include <algorithm> using namespace std; long long int c[200005]; vector<int> find_subset(int l, int u, vector<int> a) { vector<pair<int, int>> v; v.push_back({0, 0}); for (int i = 0; i < a.size(); i++) { v.push_back({a[i], i}); } sort(v.begin(), v.end()); int n = v.size() - 1; for (int i = 1; i <= n; i++) c[i] = c[i - 1] + v[i].first; for (int i = 1; i <= n; i++) { if (c[i] > u) continue; if (c[n] - c[n - i] < l) continue; long long int h = c[i]; vector<int> vv; for (int j = 1; j <= i; j++) vv.push_back(v[j].second); if (h >= l && h <= u) return vv; for (int j = i - 1; j >= 0; j--) { h -= a[vv[j]]; h += a[v[n - i + j].second]; vv[j] = v[n - i + j].second; if (h >= l && h <= u) return vv; } } vector<int> vv; return vv; }

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

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:9:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |     for (int i = 0; i < a.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...