답안 #1078392

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1078392 2024-08-27T16:36:02 Z sqrteipi Detecting Molecules (IOI16_molecules) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main(){
  int n, l, r;
  cin >> n >> l >> r;
  vector<pair<int, int>> vec;
  for (int i=0; i<n; i++) {
    int k;
    cin >> k;
    vec.push_back({k, i});
  }
  sort(vec.begin(), vec.end());
  int mi = 0, ma = 0, li = 0, ri = n - 1;
  while (li < n) {
    mi += vec[li].first, ma += vec[ri].first;
    if (l <= mi && mi <= r) {
      cout << li + 1 << "\n";
      for (int i=0; i<=li; i++) cout << vec[i].second << " ";
      return 0;
    }
    if (l <= ma && ma <= r) {
      cout << li + 1 << "\n";
      for (int i=ri; i<n; i++) cout << vec[i].second << " ";
      return 0;
    }
    if (mi <= l && r <= ma) {
      int sum = mi - vec[li].first;
      for (int i=li; i<n; i++) {
        sum += vec[i].first;
        if (l <= sum && sum <= r) {
          cout << li + 1 << "\n";
          for (int j=i-li; j<=i; j++) cout << vec[j].second << " ";
          return 0;
        }
        sum -= vec[i-li].first;
      }
    }
    li++, ri--;
  }
  cout << 0;
}

Compilation message

/usr/bin/ld: /tmp/ccP9sfNq.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccLtul6o.o:molecules.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccP9sfNq.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