# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
226371 | MKopchev | Hacker (BOI15_hac) | C++14 | 260 ms | 8800 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
const int nmax=5e5+42;
int n,inp[nmax];
long long pref[nmax];
int take;
long long ask(int l,int r)
{
while(l>n)l=l-n;
while(r>n)r=r-n;
if(l<=r)return pref[r]-pref[l-1];
return pref[r]+pref[n]-pref[l-1];
}
bool can(long long want)
{
int now=0;
for(int i=1;i<=2*n;i++)
{
if(ask(i,i+take-1)>=want)now++;
else now=0;
if(now>=take)
{
return 1;
}
}
return 0;
}
int main()
{
scanf("%i",&n);
for(int i=1;i<=n;i++)scanf("%i",&inp[i]);
take=(n+1)/2;
for(int i=1;i<=n;i++)pref[i]=pref[i-1]+inp[i];
long long ok=0,not_ok=1e18;
while(not_ok-ok>1)
{
long long av=(ok+not_ok)/2;
if(can(av))ok=av;
else not_ok=av;
}
printf("%lld\n",ok);
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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |