Submission #1119489

#TimeUsernameProblemLanguageResultExecution timeMemory
1119489MarszpaceDetecting Molecules (IOI16_molecules)C++14
100 / 100
43 ms10580 KiB
#include "molecules.h" #include<bits/stdc++.h> using namespace std; #define int long long vector<signed> find_subset(signed l, signed u, vector<signed> 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=(int)0; queue<int> qq; for(auto [wi,pos]:p){ sum+=wi; qq.push(pos); if(l<=sum&&sum<=u){ vector<signed> 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<signed>(0); }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:8:16: 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(int i=0;i<w.size();i++){
      |               ~^~~~~~~~~
molecules.cpp:15:12: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   15 |   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...