Submission #533866

#TimeUsernameProblemLanguageResultExecution timeMemory
533866M_WDetecting Molecules (IOI16_molecules)C++14
69 / 100
41 ms5560 KiB
#include "molecules.h" #include <bits/stdc++.h> #define ii pair<int, int> using namespace std; std::vector<int> find_subset(int l, int u, std::vector<int> w) { vector<ii> a; for(int i = 0; i < w.size(); i++) a.push_back({w[i], i}); sort(a.begin(), a.end()); int k = 0, pref = 0, suf = 0; for(; k < w.size(); k++){ pref += a[k].first; suf += a[w.size() - k - 1].first; if(pref <= u && suf >= l) break; } for(int i = k; i < w.size(); i++){ if(pref >= l && pref <= u){ vector<int> ans; for(int j = i - k; j <= i; j++) ans.push_back(a[j].second); return ans; } pref += a[i + 1].first - a[i - k].first; } return std::vector<int>(0); }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:8:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |  for(int i = 0; i < w.size(); i++) a.push_back({w[i], i});
      |                 ~~^~~~~~~~~~
molecules.cpp:12:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |  for(; k < w.size(); k++){
      |        ~~^~~~~~~~~~
molecules.cpp:17:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |  for(int i = k; i < w.size(); i++){
      |                 ~~^~~~~~~~~~
#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...