Submission #774597

#TimeUsernameProblemLanguageResultExecution timeMemory
774597JMsDetecting Molecules (IOI16_molecules)C++17
100 / 100
39 ms4936 KiB
#include <bits/stdc++.h> using namespace std; vector<int> find_subset(int l, int u, vector<int> w) { unsigned const long long tam = 200005; long long aux, ph, pl, s; vector <int> result; vector<pair<int, int> > v; for( long long i=0; i<w.size(); i++){ v.push_back(make_pair(w[i], i)); } sort(v.begin(), v.end()); pl=0; ph=0; s=v[0].first; while(1){ //cout<<pl<<" "<<ph<<" "<<s<<endl; if(s<l && ph<w.size()-1){ ph++; s+=v[ph].first; } else if(s>u && pl<ph){ s-=v[pl].first; pl++; } else if( s>u || s<l ){ return vector<int>(); break; } else{ for( long long i=pl; i<=ph; i++){ //cout<<v[i].second<<" "; result.push_back(v[i].second); } //cout<<endl; break; } } return result; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:11:30: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |         for( long long i=0; i<w.size(); i++){
      |                             ~^~~~~~~~~
molecules.cpp:20:25: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |             if(s<l && ph<w.size()-1){
      |                       ~~^~~~~~~~~~~
molecules.cpp:7:35: warning: unused variable 'tam' [-Wunused-variable]
    7 |         unsigned  const long long tam = 200005;
      |                                   ^~~
molecules.cpp:8:19: warning: unused variable 'aux' [-Wunused-variable]
    8 |         long long aux, ph, pl, s;
      |                   ^~~
#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...