Submission #640183

#TimeUsernameProblemLanguageResultExecution timeMemory
640183ymmDetecting Molecules (IOI16_molecules)C++17
100 / 100
44 ms6176 KiB
#include "molecules.h" #include <bits/stdc++.h> #define Loop(x,l,r) for (ll x = (l); x < (r); ++x) #define LoopR(x,l,r) for (ll x = (r)-1; x >= (l); --x) typedef long long ll; typedef std::pair<int, int> pii; typedef std::pair<ll , ll > pll; using namespace std; std::vector<int> find_subset(int l, int u, std::vector<int> _w) { vector<pii> w; Loop (i,0,_w.size()) w.emplace_back(_w[i], i); sort(w.begin(), w.end()); reverse(w.begin(), w.end()); ll sum = 0; int a = 0, b = w.size(); while (sum < l && a < w.size()) sum += w[a++].first; if (sum < l) return {}; while (sum > u && a > 0) { sum += w[--b].first; sum -= w[--a].first; } if (sum > u) return {}; vector<int> ans; Loop (i,0,a) ans.push_back(w[i].second); Loop (i,b,w.size()) ans.push_back(w[i].second); 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:12:2: note: in expansion of macro 'Loop'
   12 |  Loop (i,0,_w.size())
      |  ^~~~
molecules.cpp:18:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |  while (sum < l && a < w.size())
      |                    ~~^~~~~~~~~~
molecules.cpp:3:40: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    3 | #define Loop(x,l,r) for (ll x = (l); x < (r); ++x)
      |                                        ^
molecules.cpp:31:2: note: in expansion of macro 'Loop'
   31 |  Loop (i,b,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...