Submission #380449

#TimeUsernameProblemLanguageResultExecution timeMemory
380449saarang123Detecting Molecules (IOI16_molecules)C++17
0 / 100
1 ms364 KiB
#include <bits/stdc++.h> #include "molecules.h" using namespace std; vector<int> find_subset(int l, int r, vector<int> w) { using ll = long long; vector<array<ll, 2>> a; for(int i = 0; i < w.size(); i++) a.push_back({w[i], i + 1}); sort(a.begin(), a.end()); vector<int> ans; int j = 0, n = a.size(); ll sum = 0; for(int i = 0; i < n; i++) { while(j < n && sum < l) sum += a[j++][0]; if(l <= sum && sum <= r) { for(int k = i; k < j; k++) ans.push_back(a[k][1]); return ans; } sum -= a[i][0]; } return ans; }

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++)
      |                 ~~^~~~~~~~~~
#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...