Submission #617835

#TimeUsernameProblemLanguageResultExecution timeMemory
617835SAADDetecting Molecules (IOI16_molecules)C++17
9 / 100
1 ms244 KiB
#define F first #define S second #define rep(i,a,b) for(int i=a;!(a==b&&i!=b)&&((i<=b&&b>=a)||(i>=b&&a>=b));i+=(a<=b?1:-1)) #define pb push_back #define Fbitl __builtin_ffs #define bit1 __builtin_popcount #include <iostream> #include <math.h> #include <algorithm> #include <string.h> #include <vector> #include <queue> #include <map> #include <unordered_map> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef pair<string, string> pss; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<pii> vii; typedef vector<ll> vl; typedef vector<vl> vvl; #include "molecules.h" vector<int> find_subset(int l, int u, vector<int> w) { vii s; for (int i = 0; i < w.size(); i++) { s.push_back({w[i],i}); } sort(s.begin(), s.end()); vi res; int sum = 0 ; bool th = false; for (int i = s.size() - 1; i >= 0; i--) { if (sum + s[i].F <= u) { res.push_back(s[i].S); sum += s[i].F; } if (sum >= l && sum <= u) { th = true; break; } } if ( !th ) return vector<int>(0); return res; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:30:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |     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...