Submission #616229

#TimeUsernameProblemLanguageResultExecution timeMemory
616229jairRSDetecting Molecules (IOI16_molecules)C++17
0 / 100
1 ms212 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; using vi = vector<int>; using pii = pair<long long, long long>; #ifndef LOCALDEBUG #define LOCALDEBUG false #endif vi find_subset(int l, int u, vi w) { vector<pii> molecules; for (int i = 0; i < w.size(); i++) molecules.push_back({w[i], i}); sort(molecules.begin(), molecules.end()); long long curSum = 0; for (int i = 0; i < molecules.size(); i++) { pii cur = molecules[i]; curSum += cur.first; if(curSum > u){ //find w_p int p = -1; for (int j = 0; j <= i; j++) { long long newSum = curSum - molecules[j].first; if(l <= newSum && newSum <= u){ p = j; break; } } if(p == -1) return vi(); vi ans; for (int k = 0; k <= i; k++) { if(k == p) continue; ans.push_back(molecules[k].second); } return ans; } } return vi(); }

Compilation message (stderr)

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