Submission #1119488

#TimeUsernameProblemLanguageResultExecution timeMemory
1119488MarszpaceDetecting Molecules (IOI16_molecules)C++14
69 / 100
41 ms5776 KiB
#include "molecules.h" #include<bits/stdc++.h> using namespace std; vector<int> find_subset(int l, int u, vector<int> w) { vector<pair<int,int>> p; for(int i=0;i<w.size();i++){ p.push_back({w[i],i}); } sort(p.begin(),p.end(),greater<pair<int,int>>()); int sum=0; queue<int> qq; for(auto [wi,pos]:p){ sum+=wi; qq.push(pos); if(l<=sum&&sum<=u){ vector<int> ans; while(!qq.empty()){ ans.push_back(qq.front()); qq.pop(); } return ans; } else{ while(sum>u){ sum-=w[qq.front()]; qq.pop(); } } } return vector<int>(0); }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:7:16: 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:14:12: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   14 |   for(auto [wi,pos]:p){
      |            ^
#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...