Submission #864678

#TimeUsernameProblemLanguageResultExecution timeMemory
864678LibDetecting Molecules (IOI16_molecules)C++14
100 / 100
37 ms6492 KiB
#include <bits/stdc++.h> #include "molecules.h" using namespace std; int val[200003]; pair <int,int> val2[200003]; vector <int> find_subset(int l, int u, vector <int> w){ for(int i=0;i<w.size();i++){ val[i+1]=w[i]; val2[i+1]={val[i+1],i+1}; } sort(val2+1,val2+w.size()+1); int p1=1,p2=1; vector <int> ans; ans.clear(); long long curweight=0; while(p2<=w.size()&&curweight<l){ curweight+=val2[p2].first; p2++; } if(curweight>=l&&curweight<=u){ for(int i=p1;i<p2;i++){ ans.push_back(val2[i].second-1); } return ans; }else{ p2--; while(p2<=w.size()){ p2++; curweight+=val2[p2].first; while(curweight>u&&p1<=p2){ curweight-=val2[p1].first; p1++; } if(curweight>=l&&curweight<=u){ for(int i=p1;i<=p2;i++){ ans.push_back(val2[i].second-1); } return ans; } } return ans; } }

Compilation message (stderr)

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