Submission #739012

#TimeUsernameProblemLanguageResultExecution timeMemory
739012ThylOneDetecting Molecules (IOI16_molecules)C++14
0 / 100
1 ms212 KiB
#include "molecules.h" #include<bits/stdc++.h> using namespace std; std::vector<int> find_subset(int l, int u, std::vector<int> w) { vector<int> prefixSum; prefixSum.push_back(0); for(int i=0;i<w.size();i++){ prefixSum.push_back(prefixSum[i]+w[i]); } vector<int> R; for(int I=0;I<w.size();I++){ if(w[I]>=l && w[I]<=u){return {I};} int left = 0; int right = I; int score = prefixSum[right+1]-prefixSum[left]; while(!(score>=l && score<=u) && left<right){ int mid = (left+right)/2; if(score>u){ left = mid; }else if(score<l){ right=mid-1; }else{ } score = prefixSum[right+1]-prefixSum[left]; } if(score>=l && score<=u){ return {left,I}; } } return {}; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:8:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |  for(int i=0;i<w.size();i++){
      |              ~^~~~~~~~~
molecules.cpp:12:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |  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...