Submission #787338

#TimeUsernameProblemLanguageResultExecution timeMemory
787338ymmDetecting Molecules (IOI16_molecules)C++17
100 / 100
44 ms8220 KiB
#include "molecules.h" #include <bits/stdc++.h> #define Loop(x,l,r) for (ll x = (l); x < (r); ++x) typedef long long ll; typedef std::pair<ll,ll> pll; using namespace std; std::vector<int> find_subset(int l, int u, std::vector<int> _w) { vector<pll> w; Loop (i,0,_w.size()) w.emplace_back(_w[i], i); sort(w.begin(), w.end(), greater<pll>()); ll sum = 0; int p = 0; while (sum < l && p < w.size()) sum += w[p++].first; if (sum < l) return {}; int p2 = w.size(); while (p > 0 && sum > u) { sum -= w[--p].first; sum += w[--p2].first; } if (sum > u) return {}; vector<int> ans; Loop (i,0,p) ans.push_back(w[i].second); Loop (i,p2,w.size()) ans.push_back(w[i].second); sort(ans.begin(), ans.end()); return ans; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:3:40: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    3 | #define Loop(x,l,r) for (ll x = (l); x < (r); ++x)
      |                                        ^
molecules.cpp:10:2: note: in expansion of macro 'Loop'
   10 |  Loop (i,0,_w.size())
      |  ^~~~
molecules.cpp:15:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |  while (sum < l && p < w.size())
      |                    ~~^~~~~~~~~~
molecules.cpp:3:40: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    3 | #define Loop(x,l,r) for (ll x = (l); x < (r); ++x)
      |                                        ^
molecules.cpp:29:2: note: in expansion of macro 'Loop'
   29 |  Loop (i,p2,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...