Submission #101291

#TimeUsernameProblemLanguageResultExecution timeMemory
101291chunghanDetecting Molecules (IOI16_molecules)C++17
0 / 100
3 ms512 KiB
#include<bits/stdc++.h> #include"molecules.h" using namespace std; typedef long long int lld; typedef pair<int, int> pii; vector<int> find_subset(int l, int u, vector<int> w) { vector<pii> p; vector<int> rst; vector<lld> S; int a = 0, b = 0, sum = 0; for (int i = 0; i < (int)w.size(); i++) p.push_back(pii(w[i], i)); sort(p.begin(), p.end()); S.push_back(p[0].first); for (int i = 1; i < (int)p.size(); i++) S.push_back(S[i-1] + p[i].first); while (1) { if (sum > u) sum -= S[a++]; else if (sum < l) sum += S[b++]; else if ((sum >= l && sum <= u) || (b == w.size())) break; } for (int i = a; i <= b; i++) rst.push_back(p[i].second); return rst; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:23:47: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         else if ((sum >= l && sum <= u) || (b == w.size())) break;
                                             ~~^~~~~~~~~~~
#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...