Submission #331023

#TimeUsernameProblemLanguageResultExecution timeMemory
331023Drew_Detecting Molecules (IOI16_molecules)C++14
100 / 100
62 ms6240 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; #define ll long long #define ii pair<int,int> #define pb push_back #define f1 first #define s2 second vector<int> find_subset(int l, int u, vector<int> w) { vector<ii> v; for (int i = 0; i < w.size(); ++i) { if (w[i] > u) continue; else if (l <= w[i] && w[i] <= u) { vector<int> res; res.pb(i); return res; } else { v.pb({w[i], i}); } } sort(v.begin(), v.end()); queue<ii> q; ll val = 0; for (ii x : v) { val += x.f1; q.push(x); while (!q.empty() && val > u) { val -= q.front().f1; q.pop(); } if (l <= val && val <= u) { vector<int> res; while (!q.empty()) res.pb(q.front().s2), q.pop(); return res; } } return vector<int>(0); }

Compilation message (stderr)

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