Submission #394522

#TimeUsernameProblemLanguageResultExecution timeMemory
394522idk321Detecting Molecules (IOI16_molecules)C++11
9 / 100
1 ms272 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; std::vector<int> find_subset(int l, int u, std::vector<int> w) { ll lsum = 0; ll rsum = 0; vector<int> res; sort(w.begin(), w.end()); for (int i = 0; i < w.size(); i++) { lsum += w[i]; rsum += w[w.size() - 1 - i]; if (lsum <= u && rsum >= l) { int a = 0; int b = a + i; while (res.size() < i + 1) { while (b + 1 < w.size() && lsum - w[a] + w[b + 1] <= u) { lsum = lsum - w[a] + w[b + 1]; a++; b++; } res.push_back(a); a++; } break; } } return res; } /* 7 15 16 5 5 5 5 6 6 6 */

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:14:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |     for (int i = 0; i < w.size(); i++)
      |                     ~~^~~~~~~~~~
molecules.cpp:22:31: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   22 |             while (res.size() < i + 1)
      |                    ~~~~~~~~~~~^~~~~~~
molecules.cpp:24:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |                 while (b + 1 < w.size() && lsum - w[a] + w[b + 1] <= u)
      |                        ~~~~~~^~~~~~~~~~
#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...