Submission #491957

#TimeUsernameProblemLanguageResultExecution timeMemory
491957franfillDetecting Molecules (IOI16_molecules)C++17
100 / 100
51 ms6076 KiB
#include<bits/stdc++.h> #include "molecules.h" using namespace std; typedef long long ll; typedef pair < ll , ll > 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()); ll l = 0; ll sum = ws[0].first; for (ll 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:10:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |  for (int i = 0; i < w.size(); i++)
      |                  ~~^~~~~~~~~~
molecules.cpp:18:19: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |  for (ll r = 1; r <= w.size(); r++)
      |                 ~~^~~~~~~~~~~
molecules.cpp:33:9: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |   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...