Submission #15820

#TimeUsernameProblemLanguageResultExecution timeMemory
15820ggoh전봇대 (KOI13_pole)C++98
100 / 100
46 ms1864 KiB
#include<cstdio> #include<algorithm> long long i,x[100005],a,m,M,p,q,h; long long abs(long long z, long long w){return z>w?z-w:w-z;} long long f(long long t) { m=0; for(i=0;i<a;i++) { m+=abs(x[i],i*t); } return m; } main() { scanf("%lld",&a); for(i=0;i<a;i++)scanf("%lld",&x[i]); p=0;q=1e9; while(p!=q-1) { h=(p+q)/2; if(f(h)<f(h+1))q=h; else p=h; } printf("%lld",std::min(f(p),f(q))); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...