Submission #305925

#TimeUsernameProblemLanguageResultExecution timeMemory
305925kylych03Detecting Molecules (IOI16_molecules)C++14
100 / 100
77 ms5240 KiB
#include "molecules.h" #include <bits/stdc++.h> //#include "grader.cpp" using namespace std; std::vector<int> find_subset(int l, int u, std::vector<int> w) { vector <int> res; vector <long long> pr; vector <pair<int, int> > a; a.resize(w.size()); pr.resize(w.size()+1); for(int i = 0 ; i < w.size(); i++){ a[i].first = w[i]; a[i].second = i; } sort(a.begin(), a.end()); pr[0]=0; for(int i = 0 ; i < w.size(); i++){ pr[i+1] =pr[i] + a[i].first; } int cnt=0; for(int i=1;i<=a.size(); i++){ if(pr[i] - pr[cnt] > u ){ cnt++; } if(pr[i] - pr[cnt] <= u && pr[i] - pr[cnt]>=l){ for(int j = cnt;j<i; j++ ) res.push_back(a[j].second); break; } } return res; }

Compilation message (stderr)

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