Submission #781497

#TimeUsernameProblemLanguageResultExecution timeMemory
781497mindiyakDetecting Molecules (IOI16_molecules)C++14
0 / 100
1 ms340 KiB
#include "molecules.h" #include <algorithm> #include <vector> // #include <iostream> #define ll unsigned long long #define mp make_pair #define pb push_back using namespace std; vector<int> find_subset(int l, int u, vector<int> w) { vector<pair<ll,ll>> arr; for(ll i=0;i<w.size();i++){ arr.pb(mp(w[i],i)); } sort(arr.begin(),arr.end()); ll sum = 0; vector<int> answer; if(l<= sum and sum <= u){ return answer; } int r=0; while(r < w.size()){ while(sum < l){ answer.pb(arr[r].second); sum += arr[r].first; r++; } if(l<= sum and sum <= u){ return answer; } // cout << arr[i].first << " " << sum << endl; while(sum > u){ sum -= arr[answer[0]].first; // cout << "remove " << answer[0] << " by " << arr[answer[0]].first << " to " << sum << endl; answer.erase(answer.begin()); } if(l<= sum and sum <= u){ return answer; } } return vector<int>(0); }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:21:9: warning: comparison of integer expressions of different signedness: 'int' and 'long long unsigned int' [-Wsign-compare]
   21 |     if(l<= sum and sum <= u){
      |        ~^~~~~~
molecules.cpp:21:24: warning: comparison of integer expressions of different signedness: 'long long unsigned int' and 'int' [-Wsign-compare]
   21 |     if(l<= sum and sum <= u){
      |                    ~~~~^~~~
molecules.cpp:26:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |     while(r < w.size()){
      |           ~~^~~~~~~~~~
molecules.cpp:27:19: warning: comparison of integer expressions of different signedness: 'long long unsigned int' and 'int' [-Wsign-compare]
   27 |         while(sum < l){
      |               ~~~~^~~
molecules.cpp:33:13: warning: comparison of integer expressions of different signedness: 'int' and 'long long unsigned int' [-Wsign-compare]
   33 |         if(l<= sum and sum <= u){
      |            ~^~~~~~
molecules.cpp:33:28: warning: comparison of integer expressions of different signedness: 'long long unsigned int' and 'int' [-Wsign-compare]
   33 |         if(l<= sum and sum <= u){
      |                        ~~~~^~~~
molecules.cpp:37:19: warning: comparison of integer expressions of different signedness: 'long long unsigned int' and 'int' [-Wsign-compare]
   37 |         while(sum > u){
      |               ~~~~^~~
molecules.cpp:43:13: warning: comparison of integer expressions of different signedness: 'int' and 'long long unsigned int' [-Wsign-compare]
   43 |         if(l<= sum and sum <= u){
      |            ~^~~~~~
molecules.cpp:43:28: warning: comparison of integer expressions of different signedness: 'long long unsigned int' and 'int' [-Wsign-compare]
   43 |         if(l<= sum and sum <= u){
      |                        ~~~~^~~~
#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...