Submission #774667

#TimeUsernameProblemLanguageResultExecution timeMemory
774667Sandarach151Detecting Molecules (IOI16_molecules)C++17
100 / 100
53 ms6200 KiB
#include<bits/stdc++.h> using namespace std; vector<int> find_subset(int l, int u, vector<int> temp) { vector<pair<int, int>> w; for(int i=0; i<temp.size(); i++){ w.push_back({temp[i], i}); } sort(w.begin(), w.end()); int pos1 = 0; int pos2 = 0; long long cursum = w[0].first; vector<int> ans; bool res = true; while(true){ if(cursum<l){ pos2++; if(pos2<w.size()){ cursum+=w[pos2].first; } else{ res = false; break; } } else if(cursum>u){ cursum-=w[pos1].first; pos1++; if(pos1>pos2){ res = false; break; } } else{ break; } } if(res==false){ return ans; } else{ for(int i=pos1; i<=pos2; i++){ ans.push_back(w[i].second); } return ans; } }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:6:19: 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<temp.size(); i++){
      |                  ~^~~~~~~~~~~~
molecules.cpp:18:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |             if(pos2<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...