Submission #164673

#TimeUsernameProblemLanguageResultExecution timeMemory
164673aggu_01000101Detecting Molecules (IOI16_molecules)C++14
100 / 100
103 ms8424 KiB
#include <iostream> #include <vector> #include <algorithm> #define int long long using namespace std; vector<int32_t> find_subset(int32_t l, int32_t u, vector<int32_t> arr){ vector<pair<int, int32_t>> arr1; for(int i = 0;i<arr.size();i++){ arr1.push_back(make_pair(arr[i], i)); } sort(arr1.begin(), arr1.end()); vector<int32_t> answer; int first = 0, last = 0; int sum = 0; while(last<=arr1.size() && first<arr.size()){ if(sum>=l && sum<=u){ for(int i = first;i<last;i++){ answer.push_back(arr1[i].second); } goto returnanswer; } else if(sum<l){ if(last<arr1.size()) sum+=arr1[last].first; last++; } else{ sum-=arr1[first].first; first++; } } returnanswer: return answer; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int32_t, int32_t, std::vector<int>)':
molecules.cpp:8:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0;i<arr.size();i++){
                   ~^~~~~~~~~~~
molecules.cpp:15:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     while(last<=arr1.size() && first<arr.size()){
           ~~~~^~~~~~~~~~~~~
molecules.cpp:15:37: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     while(last<=arr1.size() && first<arr.size()){
                                ~~~~~^~~~~~~~~~~
molecules.cpp:23:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if(last<arr1.size()) sum+=arr1[last].first;
                ~~~~^~~~~~~~~~~~
#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...