제출 #424247

#제출 시각아이디문제언어결과실행 시간메모리
424247Harry464A Difficult(y) Choice (BOI21_books)C++14
컴파일 에러
0 ms0 KiB
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include "books.h"

using namespace std;
typedef long long ll;


void solve(int N, int K, long long A, int S){


  vector <ll> srch(N+1. -1);

  ll suma = 0;

  for (int i = 1; i <= min(N,K); i++){

    srch[i] = skim(i);
    suma += srch[i];

  }

  if (suma > 2*A)
    impossible();

  vector <int> odg;

  if (suma >= A && suma <= 2*A){

     for (i = 1; i <= K; i++)
        odg.push_back(i);

     answer(odg);

  }

  ll l = 1, r = N + 1;

  while (l < r){

    ll mid = (l+r)/2;
    srch[mid] = skim(mid);

    if (srch[mid] >= A)
      r = mid;
    else
      l = mid + 1;

  }

  for (int i = min(N,l); i >= max(0, l - K); i--){

    if (srch[i] == -1)
      srch[i] = skim(i);

  }
  
  if (l > K && l <= N){
    
    ll nsuma = suma - srch[K] + srch[l];
    
    if (nsuma >= A && nsuma <= 2*A){
        
        for (int i = 1; i <= K -1; i++)
            odg.push_back(i);
        odg.push_back(l);
        
        answer(odg);
        
    }
    
  }

  vector <bool> uklj(N + 1, false);
  for (int i = 1; i <= K; i++)
    uklj[i] = true;

  for (int i = 1; i <= min(K, l - K - 1); i++){

    suma -= srch[i];
    suma += srch[max(K+i, l-K+i-1)], uklj[max(K+i, l-K+i-1)] = true, uklj[i] = false;

    if (suma >= A && suma <= 2*A){

        for (int i = 1; i <= N; i++)
            if (uklj[i])
             odg.push_back(i);

        answer(odg);

    }

  }

  impossible();


}

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

books.cpp: In function 'void solve(int, int, long long int, int)':
books.cpp:32:11: error: 'i' was not declared in this scope
   32 |      for (i = 1; i <= K; i++)
      |           ^
books.cpp:53:23: error: no matching function for call to 'min(int&, ll&)'
   53 |   for (int i = min(N,l); i >= max(0, l - K); i--){
      |                       ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/ostream:38,
                 from /usr/include/c++/10/iostream:39,
                 from books.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
books.cpp:53:23: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   53 |   for (int i = min(N,l); i >= max(0, l - K); i--){
      |                       ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/ostream:38,
                 from /usr/include/c++/10/iostream:39,
                 from books.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
books.cpp:53:23: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   53 |   for (int i = min(N,l); i >= max(0, l - K); i--){
      |                       ^
In file included from /usr/include/c++/10/algorithm:62,
                 from books.cpp:4:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
books.cpp:53:23: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   53 |   for (int i = min(N,l); i >= max(0, l - K); i--){
      |                       ^
In file included from /usr/include/c++/10/algorithm:62,
                 from books.cpp:4:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
books.cpp:53:23: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   53 |   for (int i = min(N,l); i >= max(0, l - K); i--){
      |                       ^
books.cpp:53:43: error: no matching function for call to 'max(int, ll)'
   53 |   for (int i = min(N,l); i >= max(0, l - K); i--){
      |                                           ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/ostream:38,
                 from /usr/include/c++/10/iostream:39,
                 from books.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
books.cpp:53:43: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   53 |   for (int i = min(N,l); i >= max(0, l - K); i--){
      |                                           ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/ostream:38,
                 from /usr/include/c++/10/iostream:39,
                 from books.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
books.cpp:53:43: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   53 |   for (int i = min(N,l); i >= max(0, l - K); i--){
      |                                           ^
In file included from /usr/include/c++/10/algorithm:62,
                 from books.cpp:4:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
books.cpp:53:43: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   53 |   for (int i = min(N,l); i >= max(0, l - K); i--){
      |                                           ^
In file included from /usr/include/c++/10/algorithm:62,
                 from books.cpp:4:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
books.cpp:53:43: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   53 |   for (int i = min(N,l); i >= max(0, l - K); i--){
      |                                           ^
books.cpp:80:40: error: no matching function for call to 'min(int&, ll)'
   80 |   for (int i = 1; i <= min(K, l - K - 1); i++){
      |                                        ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/ostream:38,
                 from /usr/include/c++/10/iostream:39,
                 from books.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
books.cpp:80:40: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   80 |   for (int i = 1; i <= min(K, l - K - 1); i++){
      |                                        ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/ostream:38,
                 from /usr/include/c++/10/iostream:39,
                 from books.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
books.cpp:80:40: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   80 |   for (int i = 1; i <= min(K, l - K - 1); i++){
      |                                        ^
In file included from /usr/include/c++/10/algorithm:62,
                 from books.cpp:4:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
books.cpp:80:40: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   80 |   for (int i = 1; i <= min(K, l - K - 1); i++){
      |                                        ^
In file included from /usr/include/c++/10/algorithm:62,
                 from books.cpp:4:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
books.cpp:80:40: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   80 |   for (int i = 1; i <= min(K, l - K - 1); i++){
      |                                        ^
books.cpp:83:34: error: no matching function for call to 'max(int, ll)'
   83 |     suma += srch[max(K+i, l-K+i-1)], uklj[max(K+i, l-K+i-1)] = true, uklj[i] = false;
      |                                  ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/ostream:38,
                 from /usr/include/c++/10/iostream:39,
                 from books.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
books.cpp:83:34: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   83 |     suma += srch[max(K+i, l-K+i-1)], uklj[max(K+i, l-K+i-1)] = true, uklj[i] = false;
      |                                  ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/ostream:38,
                 from /usr/include/c++/10/iostream:39,
                 from books.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
books.cpp:83:34: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   83 |     suma += srch[max(K+i, l-K+i-1)], uklj[max(K+i, l-K+i-1)] = true, uklj[i] = false;
      |                                  ^
In file included from /usr/include/c++/10/algorithm:62,
                 from books.cpp:4:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
books.cpp:83:34: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   83 |     suma += srch[max(K+i, l-K+i-1)], uklj[max(K+i, l-K+i-1)] = true, uklj[i] = false;
      |                                  ^
In file included from /usr/include/c++/10/algorithm:62,
                 from books.cpp:4:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
books.cpp:83:34: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   83 |     suma += srch[max(K+i, l-K+i-1)], uklj[max(K+i, l-K+i-1)] = true, uklj[i] = false;
      |                                  ^
books.cpp:83:59: error: no matching function for call to 'max(int, ll)'
   83 |     suma += srch[max(K+i, l-K+i-1)], uklj[max(K+i, l-K+i-1)] = true, uklj[i] = false;
      |                                                           ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/ostream:38,
                 from /usr/include/c++/10/iostream:39,
                 from books.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
books.cpp:83:59: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   83 |     suma += srch[max(K+i, l-K+i-1)], uklj[max(K+i, l-K+i-1)] = true, uklj[i] = false;
      |                                                           ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/ostream:38,
                 from /usr/include/c++/10/iostream:39,
                 from books.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
books.cpp:83:59: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   83 |     suma += srch[max(K+i, l-K+i-1)], uklj[max(K+i, l-K+i-1)] = true, uklj[i] = false;
      |                                                           ^
In file included from /usr/include/c++/10/algorithm:62,
                 from books.cpp:4:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
books.cpp:83:59: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   83 |     suma += srch[max(K+i, l-K+i-1)], uklj[max(K+i, l-K+i-1)] = true, uklj[i] = false;
      |                                                           ^
In file included from /usr/include/c++/10/algorithm:62,
                 from books.cpp:4:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
books.cpp:83:59: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   83 |     suma += srch[max(K+i, l-K+i-1)], uklj[max(K+i, l-K+i-1)] = true, uklj[i] = false;
      |                                                           ^