Submission #957336

#TimeUsernameProblemLanguageResultExecution timeMemory
957336Alexabcde1Detecting Molecules (IOI16_molecules)C++14
10 / 100
1058 ms348 KiB
#include "molecules.h" #include<bits/stdc++.h> #define f first #define s second using namespace std; long long ll,rr; vector<pair<long long,long long> > ve; vector<int> find_subset(int l, int u, std::vector<int> w) { vector<int> ans; for (int i=0;i<w.size();i++){ ve.push_back({w[i],i}); } sort(ve.begin(),ve.end()); for (int i=1;i<w.size();i++) ve[i].f+=ve[i-1].f; ll=0; rr=0; while (rr<w.size()){ long long sum=ve[rr].f; if (ll!=0) sum-=ve[ll-1].f; if (l<=sum && sum<=u){ for (int ii=ll;ii<=rr;ii++) ans.push_back(ve[ii].s); sort(ans.begin(),ans.end()); return ans; } else if (sum<l) rr++; else { ll++; if (rr<ll) ll=rr; } } return ans; }

Compilation message (stderr)

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