제출 #748005

#제출 시각아이디문제언어결과실행 시간메모리
748005vjudge1A Difficult(y) Choice (BOI21_books)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
#include "books.h"
using namespace std;
long long n,k,a,s;

void solve(int N, int K, long long A, int S) {
    n=N;
    k=K;
    a=A;
    s=S;
    vector<long long>all;
    vector<int>res;
    long long sum=0;
    for(int i=1;i<=k;i++){
        all.push_back(skim(i));
        sum+=all.back();
        res.push_back(i);
    }
    if(sum>2*a){
        impossible();
        return 0;
    }
    if(suma>=a){
        answer(res);
        return 0;
    }
    int low=0,high=n+1,mid;
    while(high-low>1){
        mid=(high+low)>>1;
        if(skim(mid)>=a){
            high=mid;
        }
        else{
            low=mid;
        }
    }
    long long fake=0;
    if(high!=n+1){
        suma-=all.back();
        fake=skim(high);
        suma+=fake;
        if(suma>=a&&suma<=2*a){
            res.pop_back();
            res.push_back(high);
            answer(res);
            return 0;
        }
        suma-=fake;
        suma+=all.back();
    }
    vector<long long>all2,res2;
    long long sum2=0;
    for(int i=low-10+1;i<=low;i++){
        all2.push_back(skim(i));
        res2.push_back(low);
        sum2+=all2.back();
    }
    if(sum2<a){
        impossible();
        return 0;
    }
    while(sum<a)
    {
        sum-=all.back();
        all.pop_back();
        sum+=all2.back();
        all2.pop_back();
        res.pop_back();
    }
    int now=low;
    while((int)res2.size()<k){
        res.push_back(low);
        res2.push_back(low);
        low--;
    }
    return res;
}

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

books.cpp: In function 'void solve(int, int, long long int, int)':
books.cpp:21:16: error: return-statement with a value, in function returning 'void' [-fpermissive]
   21 |         return 0;
      |                ^
books.cpp:23:8: error: 'suma' was not declared in this scope; did you mean 'sum'?
   23 |     if(suma>=a){
      |        ^~~~
      |        sum
books.cpp:25:16: error: return-statement with a value, in function returning 'void' [-fpermissive]
   25 |         return 0;
      |                ^
books.cpp:39:9: error: 'suma' was not declared in this scope; did you mean 'sum'?
   39 |         suma-=all.back();
      |         ^~~~
      |         sum
books.cpp:46:20: error: return-statement with a value, in function returning 'void' [-fpermissive]
   46 |             return 0;
      |                    ^
books.cpp:60:16: error: return-statement with a value, in function returning 'void' [-fpermissive]
   60 |         return 0;
      |                ^
books.cpp:76:12: error: return-statement with a value, in function returning 'void' [-fpermissive]
   76 |     return res;
      |            ^~~
books.cpp:70:9: warning: unused variable 'now' [-Wunused-variable]
   70 |     int now=low;
      |         ^~~