Submission #956144

#TimeUsernameProblemLanguageResultExecution timeMemory
956144manishjha91Detecting Molecules (IOI16_molecules)C++17
19 / 100
1 ms500 KiB
#pragma once #include <bits/stdc++.h> using namespace std; std::vector<int> find_subset(int l, int u, std::vector<int> w) { std::vector<std::pair<int,int>> curr; for(int i=0; i<w.size(); i++) { curr.push_back({w[i],i}); } // sort(curr.begin(),curr.end()); long long sum = 0; bool found = 0; int low = 0; int hi = 0; for(; hi<curr.size(); hi++) { sum+=curr[hi].first; while(sum>u) { sum-=curr[low++].first; } if(sum>=l) { found = 1; break; } } if(!found) return std::vector<int>(0); std::vector<int> res; for(int i=low; i<=hi; i++) { res.push_back(curr[i].second); } sort(res.begin(),res.end()); return res; }

Compilation message (stderr)

molecules.cpp:2:9: warning: #pragma once in main file
    2 | #pragma once
      |         ^~~~
molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:11:16: 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:22:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |  for(; hi<curr.size(); hi++)
      |        ~~^~~~~~~~~~~~
#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...