제출 #398865

#제출 시각아이디문제언어결과실행 시간메모리
398865couplefireA Difficult(y) Choice (BOI21_books)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "books.h" using namespace std; void solve(int n, int k, long long goal, int s){ // binary search for first pos >= goal int lo = 0, hi = n-1, pos; while(lo < hi){ int mid = lo+(hi-lo)/2; long long val = skim(mid+1); if(val >= goal) hi = mid; else lo = mid+1; } pos = lo; long long val = skim(pos); if(val < goal) pos = n; vector<long long> ans; if(pos < k-1){ impossible(); return; } if(pos != n){ long long sum = 0; for(int i = 0; i<k-1; i++) sum += skim(i+1); if(goal <= sum+val && sum+val <= 2*goal){ for(int i = 0; i<k-1; i++) ans.push_back(i+1); ans.push_back(pos+1); answer(ans); return; } if(pos == k-1){ impossible(); return; } } vector<int> arr(n); for(int i = 0; i<k; i++) arr[i] = skim(i+1); for(int i = pos-1; i>=pos-k; i--) arr[i] = skim(i+1); for(int i = 0; i<=k; i++){ long long sum = 0; for(int j = 0; j<i; j++) sum += arr[j]; for(int j = pos-1; j>=pos-(k-i); j--) sum += arr[j]; if(goal <= sum && sum <= 2*goal){ for(int j = 0; j<i; j++) ans.push_back(j+1); for(int j = pos-1; j>=pos-(k-i); j--) ans.push_back(j+1); answer(ans); return; } } impossible(); }

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

books.cpp: In function 'void solve(int, int, long long int, int)':
books.cpp:28:20: error: could not convert 'ans' from 'vector<long long int>' to 'vector<int>'
   28 |             answer(ans);
      |                    ^~~
      |                    |
      |                    vector<long long int>
books.cpp:46:20: error: could not convert 'ans' from 'vector<long long int>' to 'vector<int>'
   46 |             answer(ans);
      |                    ^~~
      |                    |
      |                    vector<long long int>