Submission #642551

#TimeUsernameProblemLanguageResultExecution timeMemory
642551rc_catuntaDetecting Molecules (IOI16_molecules)C++17
9 / 100
1 ms212 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll,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(ll(w[i]),i)); } sort(v.begin(),v.end()); // Acumuladas vector<ll>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; long long objetivo; int pos; for(int i=0;i<a.size();i++){ if(a[i]>=l and a[i]<=u){ // Es el rango de 0 hasta i for(int k=0;k<=i;k++) res.push_back(v[k].second); return res; } // Two pointers int left=0,right=v.size()-1; while(left<right){ int ps = a[right]-a[left]; if(ps<=u and ps>=l){ for(int k=left+1;k<=right;k++) res.push_back(v[k].second); return res; } if(ps>u) right--; if(ps<l) left++; } } res.clear(); return res; }

Compilation message (stderr)

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