Submission #474697

#TimeUsernameProblemLanguageResultExecution timeMemory
474697RafaelSusDetecting Molecules (IOI16_molecules)C++14
9 / 100
1 ms204 KiB
#include <iostream> #include <vector> #include <algorithm> std::vector<int> find_subset(int l, int r, std::vector<int> a){ std::sort(a.begin(), a.end()); int pl = 0; int pr = 1; long long sum = a[0]; bool ok = true; while(true){ if (pl >= a.size() && pr >= a.size()){ ok = false; break; } if (pl > pr){ ok = false; break; } if (sum >= l and sum <= r){ break; }else if (sum < l && pr < a.size()){ pr++; sum += a[pr - 1]; }else if (sum < l && pr >= a.size()) { ok = false; break; }else if (sum > r && pl < a.size()){ sum -= a[pl]; pl++; }else if (sum > r && pl >= a.size()){ ok = false; break; } } if (ok) { std::vector<int> answ; for (int i = pl; i < pr; i++) answ.push_back(i); return answ; }else { std::vector<int> answ; return answ; } } #ifdef TEST int main(){ int l, r; unsigned int n; std::cin >> l >> r >> n; std::vector<int> a(n); for (int i = 0; i < n; i++) std::cin >> a[i]; std::vector<int> answ = find_subset(l, r, a); for (int i = 0; i < answ.size(); i++){ std::cout << answ[i] << ' '; } std::cout << '\n'; } #endif

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:13:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |         if (pl >= a.size() && pr >= a.size()){
      |             ~~~^~~~~~~~~~~
molecules.cpp:13:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |         if (pl >= a.size() && pr >= a.size()){
      |                               ~~~^~~~~~~~~~~
molecules.cpp:23:33: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |         }else if (sum < l && pr < a.size()){
      |                              ~~~^~~~~~~~~~
molecules.cpp:26:33: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |         }else if (sum < l && pr >= a.size()) {
      |                              ~~~^~~~~~~~~~~
molecules.cpp:29:33: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |         }else if (sum > r && pl < a.size()){
      |                              ~~~^~~~~~~~~~
molecules.cpp:32:33: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |         }else if (sum > r && pl >= a.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...