Submission #642548

#TimeUsernameProblemLanguageResultExecution timeMemory
642548rc_catuntaDetecting Molecules (IOI16_molecules)C++17
69 / 100
1087 ms4948 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; typedef pair<int,int> ii; vector<int> find_subset(int l, int u, vector<int> w) { vector<ii> v; for(int i=0;i<w.size();i++){ v.push_back(ii(w[i],i)); } sort(v.begin(),v.end()); // Acumuladas vector<int>a; a.push_back(v[0].first); for(int i=1;i<v.size();i++){ a.push_back(a[i-1]+v[i].first); } vector<int> res; int sum = 0; // Super Fuerza Bruta for(int i=0;i<w.size();i++){ for(int j=0;j<w.size();j++){ res.clear(); sum = a[j]; if(i>0) sum -= a[i-1]; if(sum>=l and sum<=u){ for(int k=i;k<=j;k++){ res.push_back(v[k].second); } return res; } } } res.clear(); return res; }

Compilation message (stderr)

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