Submission #138324

#TimeUsernameProblemLanguageResultExecution timeMemory
138324arthurconmyDetecting Molecules (IOI16_molecules)C++14
9 / 100
3 ms380 KiB
#include <bits/stdc++.h> #ifndef ARTHUR_LOCAL #include "molecules.h" #endif using namespace std; vector<int> find_subset(int l, int r, vector<int> W_raw) { int n = W_raw.size(); vector<pair<int,int>> W; for(int i=0; i<W_raw.size(); i++) { W.push_back(make_pair(W_raw[i],i)); } sort(W.begin(),W.end()); int cur1=0; int cur2=0; vector<int> v1; vector<int> v2; bool works=0; for(int i=1; i<=n; i++) { cur1 += W[i-1].first; v1.push_back(i-1); cur2 += W[n-i].first; v2.push_back(n-i); if(cur1 >= l && cur1 <= r) { // return cur1 things return v1; } if(cur2 >= l && cur2 <= r) { return v2; } if(cur1 < l && cur2 > r) { works=1; break; } } if(!works) return {}; for(int i=0; i<v1.size(); i++) { cur2 -= W_raw[v2[v1.size()-i-1]]; cur2 += W_raw[v1[i]]; v2[v1.size()-i-1]=v1[i]; if(cur2 <= r) return v2; } }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:13:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0; i<W_raw.size(); i++)
                  ~^~~~~~~~~~~~~
molecules.cpp:53:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0; i<v1.size(); i++)
                  ~^~~~~~~~~~
molecules.cpp:62:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
#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...