제출 #865831

#제출 시각아이디문제언어결과실행 시간메모리
865831AbdelmagedNourA Difficult(y) Choice (BOI21_books)C++17
100 / 100
1 ms864 KiB
#include <bits/stdc++.h> #include "books.h" using namespace std; typedef long long ll; ll a[100005]; ll ask(int i){ if(!a[i])a[i]=skim(i); return a[i]; } ll Sum(vector<int>v,int l,int r){ ll res=0; for(int i=l;i<=r;i++)res+=ask(v[i]); return res; } void solve(int N, int K, long long A, int S) { int l=0; for(int i=17;i>=0;i--){ int nxt=l+(1<<i); if(nxt<=N&&ask(nxt)<=A)l=nxt; } if(l<=K-2)return impossible(); vector<int>v; ll sum=0; for(int i=1;i<=K-1;i++)v.push_back(i),sum+=ask(i); if(l<N){ v.push_back(l+1); sum+=ask(l+1); if(A<=sum&&sum<=2*A)return answer(v); } if(l<K)return impossible(); vector<int>arr; for(int i=1;i<=K;i++)arr.push_back(i),arr.push_back(l-K+i); sort(arr.begin(),arr.end()); arr.erase(unique(arr.begin(),arr.end()),arr.end()); for(int i=K-1;i<arr.size();i++){ if(A<=Sum(arr,i-K+1,i)&&Sum(arr,i-K+1,i)<=2*A){ return answer(vector<int>(arr.begin()+i-K+1,arr.begin()+i+1)); } } impossible(); }

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

books.cpp: In function 'void solve(int, int, long long int, int)':
books.cpp:35:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |     for(int i=K-1;i<arr.size();i++){
      |                   ~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...