Submission #348709

#TimeUsernameProblemLanguageResultExecution timeMemory
348709NachoLibreDetecting Molecules (IOI16_molecules)C++14
0 / 100
3 ms364 KiB
#include <bits/stdc++.h> using namespace std; #ifndef wambule #include "molecules.h" #endif vector<int> find_subset(int l, int u, vector<int> w) { vector<int> dr; int n = w.size(); multiset<int> s; unsigned int sm = 0; s.insert(0); for(int i = n - 1; i >= 0; --i) { sm += w[i]; if(sm <= u) s.insert(sm); if(sm >= l) break; } sm = 0; int fl = -1, fr; if(*(--s.end()) >= l) fl = 0, fr = *(--s.end()); for(int i = 0; i < n; ++i) { sm += w[i]; if(sm >= l) { if(sm <= u) { fl = sm; fr = 0; } break; } auto it = s.lower_bound(l - sm); if(it != s.end() && sm + *it <= u) { fl = sm; fr = *it; } } if(fl != -1) { sm = 0; for(int i = 0; i < n; ++i) { sm += w[i]; if(sm > fl) break; dr.push_back(i); } sm = 0; for(int i = n - 1; i >= 0; --i) { sm += w[i]; if(sm > fr) break; dr.push_back(i); } } return dr; } #ifdef wambule int main() { ios::sync_with_stdio(0); cin.tie(0); return 0; } #endif

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:15:15: warning: comparison of integer expressions of different signedness: 'unsigned int' and 'int' [-Wsign-compare]
   15 |         if(sm <= u) s.insert(sm);
      |            ~~~^~~~
molecules.cpp:16:15: warning: comparison of integer expressions of different signedness: 'unsigned int' and 'int' [-Wsign-compare]
   16 |         if(sm >= l) break;
      |            ~~~^~~~
molecules.cpp:23:15: warning: comparison of integer expressions of different signedness: 'unsigned int' and 'int' [-Wsign-compare]
   23 |         if(sm >= l) {
      |            ~~~^~~~
molecules.cpp:24:19: warning: comparison of integer expressions of different signedness: 'unsigned int' and 'int' [-Wsign-compare]
   24 |             if(sm <= u) {
      |                ~~~^~~~
molecules.cpp:31:38: warning: comparison of integer expressions of different signedness: 'unsigned int' and 'int' [-Wsign-compare]
   31 |         if(it != s.end() && sm + *it <= u) {
      |                             ~~~~~~~~~^~~~
molecules.cpp:40:19: warning: comparison of integer expressions of different signedness: 'unsigned int' and 'int' [-Wsign-compare]
   40 |             if(sm > fl) break;
      |                ~~~^~~~
molecules.cpp:46:19: warning: comparison of integer expressions of different signedness: 'unsigned int' and 'int' [-Wsign-compare]
   46 |             if(sm > fr) break;
      |                ~~~^~~~
#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...