Submission #416965

#TimeUsernameProblemLanguageResultExecution timeMemory
416965DEQKDetecting Molecules (IOI16_molecules)C++17
9 / 100
1 ms204 KiB
#include <molecules.h> #include <bits/stdc++.h> #define ll long long using namespace std; const int N = 100100; vector<int> find_subset(int l,int u, vector<int> w) { vector<int> res; vector<ll> pref = {0}; int n = w.size(); vector<pair<int, int>> a(n); for(int i = 0; i < n; i++) { a[i] = {w[i], i}; } sort(a.begin(), a.end()); for(int i = 0; i < n; i++) { pref.push_back(pref.back() + a[i].first); } int ans = -1; for(int i = 0; i < n; i++) { int j = lower_bound(pref.begin(), pref.end(), pref[i] + l) - pref.begin(); if(j < pref.size() && pref[j] - pref[i] <= u) { int p = 0; for(i++; i <= j; i++) { res.push_back(a[i].second); } break; } } return res; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:23:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |   if(j < pref.size() && pref[j] - pref[i] <= u) {
      |      ~~^~~~~~~~~~~~~
molecules.cpp:24:8: warning: unused variable 'p' [-Wunused-variable]
   24 |    int p = 0;
      |        ^
molecules.cpp:20:6: warning: unused variable 'ans' [-Wunused-variable]
   20 |  int ans = -1;
      |      ^~~
#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...