Submission #416961

#TimeUsernameProblemLanguageResultExecution timeMemory
416961DEQKDetecting Molecules (IOI16_molecules)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define ll long long using namespace std; const int N = 100100; int find_subset(int l,int u, vector<int> w, int n, vector<int> result) { vector<pair<int, int>> a(n); vector<ll> pref = {0}; 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) { ans = 0; for(i++; i <= j; i++) { result.push_back(a[i].second); ans++; } break; } } return ans; }

Compilation message (stderr)

molecules.cpp: In function 'int find_subset(int, int, std::vector<int>, int, std::vector<int>)':
molecules.cpp:20:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |   if(j < pref.size() && pref[j] - pref[i] <= u) {
      |      ~~^~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccaMhx4d.o: in function `main':
grader.cpp:(.text.startup+0x18d): undefined reference to `find_subset(int, int, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status