제출 #725492

#제출 시각아이디문제언어결과실행 시간메모리
725492josanneo22A Difficult(y) Choice (BOI21_books)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; int arr[2e5 + 5], arr[2e5 + 5]; void solve(int N, int K, long long A, int S) { int n = N, int k = K, a = A, s = S; for (int i = 1; i <= k; i++) { arr[i]=skim(i); } int mn = 1, mx = n, loc = n + 1; long long val = 1e18; while (mn <= mx) { int mid = (mx + mx) / 2; long long tmp = skim(mid); if (tmp >= a) { val = tmp; loc = mid; mx = mid - 1; } else mn = mid + 1; } if (loc != n + 1) { long long sum = 0; for (int i = 1; i < k; i++) sum += arr[i]; sum += val; if (A <= sum && sum <= A + A) { vector<int> v; for (int i = 1; i < k; i++) v.push_back(i); v.push_back(loc); answer(v); return; } } loc--; if (loc < k) impossible(); for (int i = 1; i <= k; i++) { arr2[i] = skim(loc + 1 - i); } for (int i = 0; i <= k; i++) { long long sum = 0; for (int j = 1; j <= i; j++) sum += arr[j]; for (int j = 1; j <= k - i; j++) sum += arr2[j]; if (A <= sum && sum <= A + A) { vector<int> v; for (int j = 1; j <= i; j++) v.push_back(j); for (int j = 1; j <= k - i; j++) v.push_back(loc + 1 - j); answer(v); return; } } impossible(); }

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

books.cpp:3:13: error: conversion from 'double' to 'long unsigned int' in a converted constant expression
    3 | int arr[2e5 + 5], arr[2e5 + 5];
      |         ~~~~^~~
books.cpp:3:13: error: could not convert '(2.0e+5 + (double)5)' from 'double' to 'long unsigned int'
books.cpp:3:13: error: size of array 'arr' has non-integral type 'double'
books.cpp:3:27: error: conversion from 'double' to 'long unsigned int' in a converted constant expression
    3 | int arr[2e5 + 5], arr[2e5 + 5];
      |                       ~~~~^~~
books.cpp:3:27: error: could not convert '(2.0e+5 + (double)5)' from 'double' to 'long unsigned int'
books.cpp:3:27: error: size of array 'arr' has non-integral type 'double'
books.cpp:3:19: error: redefinition of 'int arr [1]'
    3 | int arr[2e5 + 5], arr[2e5 + 5];
      |                   ^~~
books.cpp:3:5: note: 'int arr [1]' previously declared here
    3 | int arr[2e5 + 5], arr[2e5 + 5];
      |     ^~~
books.cpp: In function 'void solve(int, int, long long int, int)':
books.cpp:5:13: error: expected unqualified-id before 'int'
    5 |  int n = N, int k = K, a = A, s = S;
      |             ^~~
books.cpp:6:23: error: 'k' was not declared in this scope
    6 |  for (int i = 1; i <= k; i++) {
      |                       ^
books.cpp:7:10: error: 'skim' was not declared in this scope
    7 |   arr[i]=skim(i);
      |          ^~~~
books.cpp:13:19: error: 'skim' was not declared in this scope
   13 |   long long tmp = skim(mid);
      |                   ^~~~
books.cpp:14:14: error: 'a' was not declared in this scope
   14 |   if (tmp >= a) {
      |              ^
books.cpp:23:23: error: 'k' was not declared in this scope
   23 |   for (int i = 1; i < k; i++) sum += arr[i];
      |                       ^
books.cpp:27:24: error: 'k' was not declared in this scope
   27 |    for (int i = 1; i < k; i++) v.push_back(i);
      |                        ^
books.cpp:29:4: error: 'answer' was not declared in this scope
   29 |    answer(v);
      |    ^~~~~~
books.cpp:35:12: error: 'k' was not declared in this scope
   35 |  if (loc < k) impossible();
      |            ^
books.cpp:35:15: error: 'impossible' was not declared in this scope
   35 |  if (loc < k) impossible();
      |               ^~~~~~~~~~
books.cpp:37:23: error: 'k' was not declared in this scope
   37 |  for (int i = 1; i <= k; i++) {
      |                       ^
books.cpp:38:3: error: 'arr2' was not declared in this scope; did you mean 'arr'?
   38 |   arr2[i] = skim(loc + 1 - i);
      |   ^~~~
      |   arr
books.cpp:38:13: error: 'skim' was not declared in this scope
   38 |   arr2[i] = skim(loc + 1 - i);
      |             ^~~~
books.cpp:41:23: error: 'k' was not declared in this scope
   41 |  for (int i = 0; i <= k; i++) {
      |                       ^
books.cpp:44:43: error: 'arr2' was not declared in this scope; did you mean 'arr'?
   44 |   for (int j = 1; j <= k - i; j++) sum += arr2[j];
      |                                           ^~~~
      |                                           arr
books.cpp:49:4: error: 'answer' was not declared in this scope
   49 |    answer(v);
      |    ^~~~~~
books.cpp:53:2: error: 'impossible' was not declared in this scope
   53 |  impossible();
      |  ^~~~~~~~~~