Submission #670960

#TimeUsernameProblemLanguageResultExecution timeMemory
670960mdubDetecting Molecules (IOI16_molecules)C++14
69 / 100
41 ms5520 KiB
#include <bits/stdc++.h> using namespace std; vector<int> find_subset(int l, int u, vector<int> w) { vector<pair<int, int>> a; for (int i = 0; i < w.size(); i++) { a.push_back({w[i], i}); } sort(a.begin(), a.end()); int left = 0; int sum = 0; for (int right = 0; right < w.size(); right++) { sum += a[right].first; while (sum > u) { sum -= a[left].first; left++; } if (sum >= l) { vector<int> ret; for (int i = left; i <= right; i++) { ret.push_back(a[i].second); } return ret; } } return {}; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:6:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    6 |   for (int i = 0; i < w.size(); i++) {
      |                   ~~^~~~~~~~~~
molecules.cpp:12:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |   for (int right = 0; right < w.size(); right++) {
      |                       ~~~~~~^~~~~~~~~~
#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...