Submission #997673

#TimeUsernameProblemLanguageResultExecution timeMemory
997673AtinaRDetecting Molecules (IOI16_molecules)C++14
9 / 100
1 ms348 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; std::vector<int> find_subset(int l, int u, std::vector<int> w) { vector<pair<long long,long long> > v; for(long long i=0; i<w.size(); i++) { v.push_back({w[i],i}); } sort(v.begin(),v.end()); long long i=0,j=0; long long sum=0; long long n=w.size(); while(j<n) { while(j<n && sum<l) { sum+=v[j].first; j++; } if(sum>=l && sum<=u) { vector<int> res; for(long long k=i; k<j; k++) { res.push_back(v[k].second); } sort(res.begin(),res.end()); return res; } sum-=v[i].first; i++; } return {}; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:8:25: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |     for(long long 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...