Submission #827477

#TimeUsernameProblemLanguageResultExecution timeMemory
827477caganyanmazDetecting Molecules (IOI16_molecules)C++11
100 / 100
50 ms8220 KiB
#include <bits/stdc++.h> #define int int64_t #define pb push_back #include "molecules.h" using namespace std; vector<int32_t> find_subset(int32_t d, int32_t u, vector<int32_t> ww) { int sum = 0; vector<array<int, 2>> w; for (int i = 0; i < ww.size(); i++) w.pb({ww[i], i}); sort(w.begin(), w.end()); int l = 0, r = 0; bool found = false; while (r < w.size()) { sum += w[r++][0]; while (sum > u) sum -= w[l++][0]; if (sum >= d) { found = true; break; } } vector<int32_t> res; if (found) while (r > l) res.pb(w[l++][1]); return res; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int32_t, int32_t, std::vector<int>)':
molecules.cpp:11:20: warning: comparison of integer expressions of different signedness: 'int64_t' {aka 'long int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |  for (int i = 0; i < ww.size(); i++)
      |                  ~~^~~~~~~~~~~
molecules.cpp:16:11: warning: comparison of integer expressions of different signedness: 'int64_t' {aka 'long int'} and 'std::vector<std::array<long int, 2> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |  while (r < w.size())
      |         ~~^~~~~~~~~~
#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...