Submission #976140

#TimeUsernameProblemLanguageResultExecution timeMemory
976140batsukh2006Detecting Molecules (IOI16_molecules)C++17
0 / 100
1 ms600 KiB
#include "molecules.h" #include<bits/stdc++.h> using namespace std; #define ff first #define ss second vector<int> find_subset(int l, int u, vector<int> w) { vector<pair<int,int> > v; for(int i=0; i<w.size(); i++){ v.push_back({w[i],i}); } queue<int> q; int sum=0,i=0; sort(v.begin(),v.end()); while(sum+v[i].ff<=l&&i<v.size()){ sum+=v[i].ff; q.push(v[i++].ss); } if(i>0){ while(sum<=l&&i<v.size()){ sum+=v[i].ff-v[q.front()].ff; q.push(v[i++].ss); q.pop(); } } vector<int> ans; if(i==0){ sum+=v[0].ff; q.push(v[0].ss); } if(sum>=l&&sum<=u){ while(!q.empty()){ ans.push_back(q.front()); q.pop(); } } return ans; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:8:16: 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:14:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |     while(sum+v[i].ff<=l&&i<v.size()){
      |                           ~^~~~~~~~~
molecules.cpp:19:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |      while(sum<=l&&i<v.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...