Submission #982598

#TimeUsernameProblemLanguageResultExecution timeMemory
982598THXuanDetecting Molecules (IOI16_molecules)C++14
100 / 100
42 ms10188 KiB
#include "molecules.h" #include <bits/stdc++.h> #define INF 1e9 using namespace std; typedef long long ll; vector<int> find_subset(int l, int u, vector<int> w) { vector<pair<ll,ll>>v; for(int i =0;i<w.size();i++) v.push_back({w[i], i}); sort(v.begin(), v.end()); ll sum = 0; int j = 0; vector<int>ans; for(int i =0;i<w.size();i++){ sum += v[i].first; while(sum > u){ sum -= v[j].first; ++j; } if(sum >= l){ for(int k = j;k<=i;k++)ans.push_back(v[k].second); break; } } return ans; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:8:19: 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++) v.push_back({w[i], i});
      |                  ~^~~~~~~~~
molecules.cpp:13:19: 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...