Submission #53967

#TimeUsernameProblemLanguageResultExecution timeMemory
53967Alexa2001Detecting Molecules (IOI16_molecules)C++17
0 / 100
3 ms756 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; vector< pair<int,int> > W; vector<ll> S; vector<int> solution(int x, int y) { vector<int> ans; for(int i=x; i<=y; ++i) ans.push_back(W[i].second); return ans; } vector<int> find_subset(int L, int R, vector<int> w) { int i, j; for(i=0; i<w.size(); ++i) W.push_back({w[i], i}); sort(W.begin(), W.end()); ll sum = 0; for(i=0; i<W.size(); ++i) { sum += W[i].first; S.push_back(sum); } j = 0; while(j<S.size() && S[j] < L) ++j; if(S[j] <= R) return solution(0, j); for(i=0; i<S.size(); ++i) { while(j<S.size() && S[j] - S[i] < L) ++j; if(j<S.size() && S[j] - S[i] <= R) return solution(i+1, j); } return vector<int> (); }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:22:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(i=0; i<w.size(); ++i) W.push_back({w[i], i});
              ~^~~~~~~~~
molecules.cpp:26:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(i=0; i<W.size(); ++i)
              ~^~~~~~~~~
molecules.cpp:33:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     while(j<S.size() && S[j] < L) ++j;
           ~^~~~~~~~~
molecules.cpp:37:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(i=0; i<S.size(); ++i)
              ~^~~~~~~~~
molecules.cpp:39:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         while(j<S.size() && S[j] - S[i] < L) ++j;
               ~^~~~~~~~~
molecules.cpp:40:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if(j<S.size() && S[j] - S[i] <= R) return solution(i+1, j);
            ~^~~~~~~~~
#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...