Submission #527032

#TimeUsernameProblemLanguageResultExecution timeMemory
527032lcs147Detecting Molecules (IOI16_molecules)C++98
100 / 100
51 ms4924 KiB
#include"molecules.h" #include<bits/stdc++.h> using namespace std; vector<int>find_subset(int l, int r, vector<int> w) { vector<int>id(w.size()); iota(id.begin(), id.end(), 0); sort(id.begin(), id.end(), [&](int a, int b){ return w[a] < w[b]; }); int i, j; long long sum = 0; for(i=0, j=0; j<id.size(); j++) { int jj = id[j]; sum += w[jj]; while(sum > r) { int ii = id[i]; sum -= w[ii]; i++; } if(sum >= l) break; } vector<int>res; if(sum >= l) { for(int x=i; x<=j; x++) { res.push_back(id[x]); } } sort(res.begin(), res.end()); return res; }

Compilation message (stderr)

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