답안 #54136

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
54136 2018-07-02T13:01:12 Z WLZ Detecting Molecules (IOI16_molecules) C++17
컴파일 오류
0 ms 0 KB
#include "molecules.h"
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

vector<int> find_subset(int n, int l, int u, vector<int> w) {
  vector< pair<int, int> > v;
  for (int i = 0; i < n; i++) {
    v.emplace_back(w[i], i);
  }
  sort(v.begin(), v.end());
  int i = 0, j = 0;
  long long cur = 0ll;
  vector<int> was(n, 0);
  int cnt = 0;
  for (;;) {
    while (i < n && cur < (long long) l) {
      was[v[i].second] = 1;
      cur += (long long) v[i++].first;      
      cnt++;
    }
    while (j < n && cur > (long long) u) {
      was[v[j].second] = 0;
      cur -= (long long) v[j++].first;
      cnt--;
    }
    if (cur >= l && cur <= u) {
      vector<int> ans;
      for (int i = 0; i < n; i++) {
        if (was[i]) {
          ans.push_back(i);
        }
      }
      return ans;
    }
    if (i >= n || j >= n) {
      break;
    }
  }
  return {};
}

Compilation message

/tmp/ccCR0PEX.o: In function `main':
grader.cpp:(.text.startup+0x152): undefined reference to `find_subset(int, int, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status