This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "books.h"
using namespace std;
//
// --- Sample implementation for the task books ---
//
// To compile this program with the sample grader, place:
// books.h books_sample.cpp sample_grader.cpp
// in a single folder and run:
// g++ books_sample.cpp sample_grader.cpp
// in this folder.
//
int n,m,s;
vector<pair<long long,int> > v;
long long a,num,qs[100005];
long long query(int l,int r)
{
if(l==0)return qs[r];
return qs[r]-qs[l-1];
}
void solve(int N, int K, long long A, int S) {
// TODO implement this function
n=N;
m=K;
a=A;
s=S;
num=a/m;
int st=1,ed=n,md;
while(ed>=st)
{
md=(st+ed)/2;
long long val=skim(md);
if(val>num)
{
ed=md-1;
}else
{
st=md+1;
}
}
//printf("%d %d %d\n",st,md,ed);
for(int i=st-m-1;i<=st-1;i++)
{
if(i>=1&&i<=n)
{
v.push_back({skim(i),i});
}
}
if(st>=1&&st<=n)
{
v.push_back({skim(st),st});
}
for(int i=st+1;i<=st+m+1;i++)
{
if(i>=1&&i<=n)
{
v.push_back({skim(i),i});
}
}
qs[0]=v[0].first;
for(int i=1;i<v.size();i++)
{
qs[i]=qs[i-1]+v[i].first;
}
for(int i=0;i<=v.size()-m;i++)
{
if(query(i,i+m-1)>=a&&query(i,i+m-1)<=2*a)
{
vector<int> ans;
for(int j=i;j<=i+m-1;j++)
{
ans.push_back(v[j].second);
}
answer(ans);
}
}
impossible();
}
Compilation message (stderr)
books.cpp: In function 'void solve(int, int, long long int, int)':
books.cpp:63:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
63 | for(int i=1;i<v.size();i++)
| ~^~~~~~~~~
books.cpp:67:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
67 | for(int i=0;i<=v.size()-m;i++)
| ~^~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |