Submission #443859

#TimeUsernameProblemLanguageResultExecution timeMemory
443859fuad27Detecting Molecules (IOI16_molecules)C++14
100 / 100
56 ms5316 KiB
#include "molecules.h" #include<bits/stdc++.h> using namespace std; vector<int> find_subset(int l, int u, vector<int> w) { vector<pair<int, int>> k(w.size()); for(int i = 0;i<w.size();i++) { k[i] = make_pair(w[i], i); } sort(k.begin(), k.end()); vector<long long> prefix(w.size()+1, 0); for(int i = 0;i<w.size();i++) { prefix[i+1] = prefix[i] + k[i].first; } int p1 = 0, p2 = 1; while(p2 <= w.size() and p1 <= w.size()) { if(prefix[p2] - prefix[p1] > u) { p1++; } else if(prefix[p2] - prefix[p1] < l) { p2++; } else if(prefix[p2] - prefix[p1] >= l and prefix[p2] - prefix[p1] <= u) { vector<int> d; for(int i = p1;i<p2;i++) { d.push_back(k[i].second); } return d; } } return {}; }

Compilation message (stderr)

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