Submission #810457

#TimeUsernameProblemLanguageResultExecution timeMemory
810457WarinchaiDetecting Molecules (IOI16_molecules)C++14
100 / 100
40 ms6176 KiB
#include "molecules.h" #include<bits/stdc++.h> using namespace std; vector<pair<int,int> >v; vector<int> find_subset(int l, int u,vector<int> w) { for(int i=0;i<w.size();i++){ v.push_back({w[i],i}); } sort(v.begin(),v.end()); deque<pair<int,int> >dq; int i=0; long long sum=0; while(i<v.size()){ //cerr<<"push back"<<i<<endl; dq.push_back(v[i]); sum+=v[i].first; //cerr<<"sum:"<<sum<<endl; //cerr<<"sums:"<<endl; while(sum>u){ //cerr<<sum<<endl; sum-=dq.front().first; dq.pop_front(); } //cerr<<"remaining"<<endl; //for(int i=0;i<dq.size();i++){ // cerr<<dq[i].second<<" "; //} //cerr<<endl; if(sum>=l){ vector<int>ans; for(int i=0;i<dq.size();i++){ ans.push_back(dq[i].second); } return ans; } i++; } return vector<int>(0); }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:6:18: 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:13:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |     while(i<v.size()){
      |           ~^~~~~~~~~
molecules.cpp:31:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::deque<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |             for(int i=0;i<dq.size();i++){
      |                         ~^~~~~~~~~~
#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...