Submission #574753

#TimeUsernameProblemLanguageResultExecution timeMemory
574753DosA Difficult(y) Choice (BOI21_books)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>

#include "books.h"

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, r;
    l = 1;
    r = n;

    int firstBook = INT_MAX;

    while(l < r)
    {
        int mid = (l+r)/2;

        ll sum = skim(mid);

        for(int i = mid+1; i < mid + k; i++)
        {
            sum += skim(i);
        }

        if(sum < A)
        {
            l = mid+1;
        } else if(sum > 2*A)
        {
            r = mid - 1;
        } else
        {
            vector<int> ans;
            for(int i = mid; i < mid + k; i++)
            {
                ans.push_back(i);
            }

            answer(ans);
        }
    }

    impossible();


}

Compilation message (stderr)

books.cpp: In function 'void solve(int, int, long long int, int)':
books.cpp:21:9: error: 'n' was not declared in this scope
   21 |     r = n;
      |         ^
books.cpp:29:9: error: 'll' was not declared in this scope; did you mean 'l'?
   29 |         ll sum = skim(mid);
      |         ^~
      |         l
books.cpp:31:38: error: 'k' was not declared in this scope
   31 |         for(int i = mid+1; i < mid + k; i++)
      |                                      ^
books.cpp:33:13: error: 'sum' was not declared in this scope
   33 |             sum += skim(i);
      |             ^~~
books.cpp:36:12: error: 'sum' was not declared in this scope
   36 |         if(sum < A)
      |            ^~~
books.cpp:45:40: error: 'k' was not declared in this scope
   45 |             for(int i = mid; i < mid + k; i++)
      |                                        ^
books.cpp:23:9: warning: unused variable 'firstBook' [-Wunused-variable]
   23 |     int firstBook = INT_MAX;
      |         ^~~~~~~~~