# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
281733 | MKopchev | Worst Reporter 3 (JOI18_worst_reporter3) | C++14 | 953 ms | 27408 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
const int nmax=5e5+42,inf=1e9+42;
int n,q;
int inp[nmax];
long long help[nmax];
int score(int i,int t)
{
return (t/help[i])*help[i]-i;
}
int last_valid(int pos,int t)
{
int ok=n+1,not_ok=-1;
while(ok-not_ok>1)
{
int av=(ok+not_ok)/2;
if(score(av,t)<=pos)ok=av;
else not_ok=av;
}
//cout<<"last "<<ok<<endl;
return ok;
}
int first_valid(int pos,int t)
{
int ok=-1,not_ok=n+1;
while(not_ok-ok>1)
{
int av=(ok+not_ok)/2;
if(score(av,t)>=pos)ok=av;
else not_ok=av;
}
//cout<<"first "<<ok<<endl;
return ok;
}
int main()
{
scanf("%i%i",&n,&q);
for(int i=1;i<=n;i++)
{
scanf("%i",&inp[i]);
}
inp[0]=1;
help[0]=1;
for(int i=1;i<=n;i++)
{
help[i]=help[i-1]*((inp[i]+help[i-1]-1)/help[i-1]);
if(help[i]>inf)help[i]=inf;
//cout<<i<<" -> "<<help[i]<<endl;
}
for(int i=1;i<=q;i++)
{
int l,r,t;
scanf("%i%i%i",&t,&l,&r);
/*
for(int j=0;j<=n;j++)
cout<<j<<" -> "<<score(j,t)<<endl;
*/
printf("%i\n",first_valid(l,t)-last_valid(r,t)+1);
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |