Submission #1019845

#TimeUsernameProblemLanguageResultExecution timeMemory
1019845SaltyDetecting Molecules (IOI16_molecules)C++14
0 / 100
0 ms348 KiB
#include "molecules.h" #include<bits/stdc++.h> using namespace std; vector<int> find_subset(int l, int u, vector<int> w) { vector<int> ans,blank; vector<int> temp; temp = w; sort(w.begin(),w.end()); unordered_map<int,int> mp; for(auto val:w){ mp[val]++; } int w1 = w[0], w2 = w[w.size()-1]; int sm = 0; for(int i = 0; i < mp[w1]; i++){ if(sm < l) { sm+=w[i]; ans.push_back(i); } else break; } if(sm <= u >= l) return ans; else return blank; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:23:11: warning: comparisons like 'X<=Y<=Z' do not have their mathematical meaning [-Wparentheses]
   23 |     if(sm <= u >= l) return ans;
      |        ~~~^~~~
molecules.cpp:14:20: warning: unused variable 'w2' [-Wunused-variable]
   14 |     int w1 = w[0], w2 = w[w.size()-1];
      |                    ^~
#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...