Submission #815251

#TimeUsernameProblemLanguageResultExecution timeMemory
815251TheSahibDetecting Molecules (IOI16_molecules)C++14
9 / 100
1 ms304 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; vector<int> find_subset(int v, int u, vector<int> w) { long long sum = 0; vector<pair<int, int>> arr; for (int i = 0; i < w.size(); i++) { arr.push_back({w[i], i}); } sort(arr.begin(), arr.end()); int l = 0, r = 0; while(l <= r){ if(sum > u){ sum -= w[l]; l++; } else if(sum < v){ if(r == w.size()){ return {}; } sum += w[r]; r++; } else{ break; } if(l > r){ return {}; } } vector<int> ans; for(int i = l; i < r; ++i){ ans.push_back(arr[i].second); } return ans; }

Compilation message (stderr)

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