Submission #491955

#TimeUsernameProblemLanguageResultExecution timeMemory
491955franfillDetecting Molecules (IOI16_molecules)C++17
69 / 100
40 ms3944 KiB
#include<bits/stdc++.h> #include "molecules.h" using namespace std; typedef pair < int , int > ii; std::vector<int> find_subset(int f, int u, std::vector<int> w) { vector < ii > ws; for (int i = 0; i < w.size(); i++) { ws.push_back({w[i], i}); } sort(ws.begin(), ws.end()); int l = 0; int sum = ws[0].first; for (int r = 1; r <= w.size(); r++) { while(sum > u) { sum -= ws[l++].first; } if (sum >= f) { vector < int > ans; for (int i = l; i < r; i++) { ans.push_back(ws[i].second); } return ans; } if (r < w.size()) sum += ws[r].first; } return {}; }

Compilation message (stderr)

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