# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
543243 | Deepesson | Hacker (BOI15_hac) | C++17 | 1092 ms | 38516 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define MAX 2100000
#define LSB(A) (A&(-A))
using ll = long long;
typedef std::pair<ll,ll> pll;
typedef std::pair<ll,pll> plp;
ll ft[MAX];
void update(int t,int k){t+=8;
while(t<MAX){
ft[t]+=k;
t+=LSB(t);
}
}
ll query(int t){t+=8;
ll ans=0;
while(t>0){
ans+=ft[t];
t-=LSB(t);
}
return ans;
}
ll seg(int l,int r){
return query(r)-query(l-1);
}
ll array[MAX];
int main()
{
std::ios::sync_with_stdio(false);
std::cin.tie(0);
std::cout.tie(0);
int N;
std::cin>>N;
long long soma=0;
for(int i=0;i!=N;++i){
std::cin>>array[i];
soma+=array[i];
}
for(int i=0;i!=MAX;++i){
array[i]=array[i%N];
}
for(int i=0;i!=MAX;++i){
update(i,array[i]);
}
ll respostas[N]={};
ll puxa=N/2;
ll ans=0;
ll left[N]={},right[N]={};
std::vector<plp> vec;
for(int i=0;i!=N;++i){
respostas[i]=seg(i,i+puxa-1);
int l = i,r=(i+puxa-1)%N;
/// std::cout<<l<<" "<<r<<" "<<respostas[i]<<"\n";
vec.push_back({respostas[i],{l,i+puxa-1}});
}
ll total[N]={};
{
for(int i=0;i!=N;++i){
for(auto&x:vec){
if(i>=x.second.first&&i<=x.second.second)continue;
if(x.second.second>=N){
int t = x.second.second%N;
if(t>=i)continue;
}
total[i]=std::max(total[i],x.first);
}
}
}
std::cout<<(soma-(*std::min_element(total,&total[N])))<<"\n";
}
컴파일 시 표준 에러 (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... |