Submission #823534

#TimeUsernameProblemLanguageResultExecution timeMemory
823534trucmaiDetecting Molecules (IOI16_molecules)C++17
0 / 100
0 ms212 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #include "molecules.h" std::vector<int> find_subset(int l, int u, std::vector<int> w) { sort(w.begin(),w.end()); vector<int>idx(w.size()); for(int i = 0;i < w.size();++i) idx[i] = i; sort(idx.begin(),idx.end(),[&](int x,int y){return w[x] < w[y];}); ll ptr = 0,sum = 0; for(ll i = 0;i < w.size();++i){ sum += w[idx[i]]; while(sum > u) sum -= w[idx[++ptr]]; while(sum <= l){ vector<int>res; for(ll j = ptr;j <= i;++j) res.push_back(j); return res; } } return vector<int>{}; }

Compilation message (stderr)

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