Submission #1042621

#TimeUsernameProblemLanguageResultExecution timeMemory
1042621ZicrusDetecting Molecules (IOI16_molecules)C++17
19 / 100
1 ms436 KiB
#include <bits/stdc++.h> #include "molecules.h" using namespace std; typedef long long ll; vector<int> find_subset(int l, int u, vector<int> w1) { ll tot = 0; ll lCnt = 0, hCnt = 0, actualHCnt = 0; vector<int> w = w1; sort(w.begin(), w.end()); ll cnt = 0; for (auto &e : w) { if (tot + e <= u) { tot += e; cnt++; if (e == w[0]) lCnt++; else actualHCnt++; } else { if (e != w[0]) hCnt++; } } ll sw = min(lCnt, hCnt); ll fin = min(tot + sw, (ll)u); ll used = fin - tot; lCnt -= used; actualHCnt += used; vector<int> res; if (fin < l) return res; ll tot2 = 0; ll l2 = used, u2 = used; for (int i = l2; i < w.size(); i++) { if (w1[i] == w[0]) { if (lCnt-- > 0) res.push_back(i); } else { if (actualHCnt-- > 0) res.push_back(i); } } return res; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:29:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |     for (int i = l2; i < w.size(); i++) {
      |                      ~~^~~~~~~~~~
molecules.cpp:27:8: warning: unused variable 'tot2' [-Wunused-variable]
   27 |     ll tot2 = 0;
      |        ^~~~
molecules.cpp:28:19: warning: unused variable 'u2' [-Wunused-variable]
   28 |     ll l2 = used, u2 = used;
      |                   ^~
#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...