제출 #1334324

#제출 시각아이디문제언어결과실행 시간메모리
1334324zhehanA Difficult(y) Choice (BOI21_books)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>

#include "books.h"
#define int long long
using namespace std;
//
// --- Sample implementation for the task books ---
//
// To compile this program with the sample grader, place:
//     books.h books_sample.cpp sample_grader.cpp
// in a single folder and run:
//     g++ books_sample.cpp sample_grader.cpp
// in this folder.
//

void solve(int N, int K, long long A, int S) {
  // TODO implement this function
  int l = 1, r = N, m, o;
  while (l < r) {
    m = (l + r) / 2;
    o = skim(m);
    if (o == A) {
      l = m;
      break;
    }
    if (o < A) {
      l = m + 1;
    } else {
      r = m;
    }
  }
  if (l < K) {
    impossible();
  }
  vector<int> selected_books(K, 0);
  vector<int> ind(K, 0);
  ind[K - 1] = l;
  selected_books[K - 1] = skim(l);
  int sum = selected_books[K - 1];
  bool offset = false;
  if (selected_books[K - 1] < A) {
    offset = true;
  }
  for (int i = 1; i < K; ++i) {
    selected_books[i - 1] = skim(i);
    ind[i - 1] = i;
    sum += selected_books[i - 1];
  }
  if (sum < 2 * A && sum > A) {
    answer(ind);
  }
  if (l == K) {
    impossible();
  }
  selected_books[K - 1] = skim(K);
  sum = sum - o + selected_books[K - 1];
  ind[K - 1] = K;
  if (sum < 2 * A && sum > A) {
    answer(ind);
  }

  for (int i = 0; i < K; ++i) {
    if (l - K + i <= K) {
      impossible();
    }
    int j = l - K + i;
    if (offset) {
      ++j;
    }
    int curr = skim(j);
    sum = sum - selected_books[i] + curr;
    selected_books[i] = curr;
    ind[i] = j;
    if (sum < 2 * A && sum > A) {
      answer(ind);
    }
  }
  impossible();
}

컴파일 시 표준 에러 (stderr) 메시지

books.cpp: In function 'void solve(long long int, long long int, long long int, long long int)':
books.cpp:50:12: error: could not convert 'ind' from 'vector<long long int>' to 'vector<int>'
   50 |     answer(ind);
      |            ^~~
      |            |
      |            vector<long long int>
books.cpp:59:12: error: could not convert 'ind' from 'vector<long long int>' to 'vector<int>'
   59 |     answer(ind);
      |            ^~~
      |            |
      |            vector<long long int>
books.cpp:75:14: error: could not convert 'ind' from 'vector<long long int>' to 'vector<int>'
   75 |       answer(ind);
      |              ^~~
      |              |
      |              vector<long long int>