Submission #269252

#TimeUsernameProblemLanguageResultExecution timeMemory
269252Bill_00Detecting Molecules (IOI16_molecules)C++14
100 / 100
65 ms5752 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; pair<int,int>p[200001]; std::vector<int> find_subset(int l, int u, std::vector<int> w){ int n=w.size(); for(int i=0;i<w.size();i++){ p[i]=make_pair(w[i],i); } sort(p,p+w.size()); vector<int>res; long long sum=0,up=-1; for(int i=0;i<w.size();i++){ sum+=(long long)p[i].first; if(sum<=(long long)u && sum>=(long long)l){ for(int j=0;j<=i;j++){ res.push_back(p[j].second); } sort(res.begin(),res.end()); return res; } if(sum>=(long long)l){ up=i-1; sum-=(long long)p[i].first; break; } } if(up==-1){ return res; } for(int i=up;i>=0;i--){ sum-=(long long)p[i].first; sum+=(long long)p[i+n-up-1].first; if(sum>=(long long)l && sum<=(long long)u){ for(int j=0;j<=i-1;j++){ res.push_back(p[j].second); } for(int j=i+n-up-1;j<n;j++){ res.push_back(p[j].second); } sort(res.begin(),res.end()); return res; } } return res; }

Compilation message (stderr)

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