Submission #720505

#TimeUsernameProblemLanguageResultExecution timeMemory
720505joelgun14Detecting Molecules (IOI16_molecules)C++17
9 / 100
1 ms256 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; std::vector<int> find_subset(int l, int u, std::vector<int> w) { // between l and u // pilih sum terkecil, terus nanti sort(w.begin(), w.end()); // cari w sesuai buat antara u l // cari first bigger than u, berarti countnya itu satu kurang dr long long sum = 0; int cnt = w.size(); for(int i = 0; i < w.size(); ++i) { sum += w[i]; if(sum > u) { cnt = i; break; } } if(cnt == 0) return vector<int>(0); multiset<int> s; sum = 0; for(int i = 0; i < cnt; ++i) { sum += w[i]; s.insert(w[i]); } multiset<int> unused; for(int i = cnt; i < w.size(); ++i) { // try to if(sum >= l) break; if(sum < l) { // coba increase to smallest above l s.insert(w[i]); sum += w[i]; sum -= *s.begin(); s.erase(s.begin()); } } if(sum >= l && sum <= u) { vector<int> ans; for(int i = 0; i < w.size(); ++i) { if(s.find(w[i]) != s.end()) { ans.push_back(i); s.erase(s.find(w[i])); } } return ans; } else { return vector<int>(0); } }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:13:22: 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) {
      |                    ~~^~~~~~~~~~
molecules.cpp:29:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |     for(int i = cnt; i < w.size(); ++i) {
      |                      ~~^~~~~~~~~~
molecules.cpp:43:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |         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...