Submission #170023

#TimeUsernameProblemLanguageResultExecution timeMemory
170023whtttDetecting Molecules (IOI16_molecules)C++14
0 / 100
2 ms376 KiB
#include <iostream> #include <vector> #include <algorithm> #define ll long long using namespace std; vector<ll> find_subset(int l, int u, vector<int> w){ ll sum = 0; vector<ll> returnThis; vector<pair<ll, ll>> sol; for(ll i = 0;i < w.size();i++){ sol.push_back({w[i],i}); } sort(sol.begin(), sol.end()); for(ll i = 0;i < sol.size();i++){ sum += sol[i].first; //cout << sum << endl; if(sum <= u && sum >= l){ for(ll j = 0;j <= i;j++){ returnThis.push_back(sol[j].second); } return returnThis; } else if(sum > l){ sum -= sol[i].first; for(ll j = i;j < w.size();j++){ sum += sol[j].first-sol[j-i].first; if(sum <= u && sum >= l){ for(ll k = j-i+1;k <= i;k++){ returnThis.push_back(sol[k].second); } return returnThis; } if(j == sol.size()-1){ return {}; } } } } return {}; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<long long int> find_subset(int, int, std::vector<int>)':
molecules.cpp:14:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(ll i = 0;i < w.size();i++){
                  ~~^~~~~~~~~~
molecules.cpp:18:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(ll i = 0;i < sol.size();i++){
                  ~~^~~~~~~~~~~~
molecules.cpp:28:28: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for(ll j = i;j < w.size();j++){
                          ~~^~~~~~~~~~
molecules.cpp:36:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 if(j == sol.size()-1){
                    ~~^~~~~~~~~~~~~~~
#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...