제출 #1115456

#제출 시각아이디문제언어결과실행 시간메모리
1115456Dan4LifeA Difficult(y) Choice (BOI21_books)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "books.h" using namespace std; #define pb push_back #define sz(a) (int)a.size() #define all(a) begin(a),end(a) using ll = long long; using vi = vector<int>; const int N = (int)1e5+10; int n, K, ind; ll A, a[N]; vi ans; ll Skim(int i){ if(a[i]!=-1) return a[i]; return a[i]=skim(i); } ll getSum(int mid, int num){ ll s = 0; for(int j = mid; j < mid+num; j++) s+=Skim(j); return s; } int bsearch(ll x){ int l = 1, r = n; while(l<r){ int mid = (l+r)/2; if(Skim(mid)>=x) r=mid; else l=mid+1; } return l; } ll chk(int mid){ ll sum = getSum(mid,K); ans.resize(K,0); iota(all(ans),mid); if(sum>=A and sum<=2*A){ answer(ans); exit(0); } ll ans = sum; if(ind>=mid+K and ind<=n and a[ind]>=A){ sum=sum-a[mid+K-1]+a[ind]; if(sum>=A and sum<=2*A){ ans[mid+K-1]=ind; answer(ans); exit(0); } } return ans; } void solve(int _N, int _K, ll _A, int S) { n = _N; A=_A,K=_K; memset(a,-1,sizeof(a)); ans.resize(K,0); int l = 1, r = n-K+1; ind = bsearch(A); while(l<r){ int mid = (l+r)/2; if(chk(mid)>2*A) r=mid-1; else l=mid+1; } chk(l); impossible(); }

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

books.cpp: In function 'll chk(int)':
books.cpp:42:31: error: invalid types 'll {aka long long int}[int]' for array subscript
   42 |   if(sum>=A and sum<=2*A){ ans[mid+K-1]=ind; answer(ans); exit(0); }
      |                               ^
books.cpp:42:53: error: could not convert 'ans' from 'll' {aka 'long long int'} to 'std::vector<int>'
   42 |   if(sum>=A and sum<=2*A){ ans[mid+K-1]=ind; answer(ans); exit(0); }
      |                                                     ^~~
      |                                                     |
      |                                                     ll {aka long long int}