Submission #5888

# Submission time Handle Problem Language Result Execution time Memory
5888 2014-05-21T08:14:18 Z baneling100 전봇대 (KOI13_pole) C++
100 / 100
32 ms 3432 KB
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>

using namespace std;

pair <long long,long long> y[100001];
long long N, x[100001], Hab, Ans;

void input(void)
{
    long long i;

    scanf("%lld",&N);
    for(i=0 ; i<N ; i++)
    {
        scanf("%lld",&x[i]);
        if(i)
            y[i]=make_pair(x[i]/i,i);
    }
    Hab=N*(N-1)/2;
    Hab=(Hab+1)/2;
    sort(y+1,y+N);
}

void process(void)
{
    long long i, s=0, v, temp=0;

    for(i=1 ; i<N ; i++)
    {
        s+=y[i].second;
        if(Hab<=s)
        {
            v=i;
            break;
        }
    }
    if(y[v].first==0)
        y[v].first++;
    for(i=1 ; i<N ; i++)
    {
        Ans+=abs(i*y[v].first-x[i]);
        temp+=abs(i*(y[v].first+1)-x[i]);
    }
    if(Ans>temp)
        Ans=temp;
}

void output(void)
{
    printf("%lld",Ans);
}

int main(void)
{
    input();
    process();
    output();

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 3432 KB Output is correct
2 Correct 0 ms 3432 KB Output is correct
3 Correct 0 ms 3432 KB Output is correct
4 Correct 0 ms 3432 KB Output is correct
5 Correct 0 ms 3432 KB Output is correct
6 Correct 0 ms 3432 KB Output is correct
7 Correct 0 ms 3432 KB Output is correct
8 Correct 0 ms 3432 KB Output is correct
9 Correct 0 ms 3432 KB Output is correct
10 Correct 0 ms 3432 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 3432 KB Output is correct
2 Correct 0 ms 3432 KB Output is correct
3 Correct 0 ms 3432 KB Output is correct
4 Correct 0 ms 3432 KB Output is correct
5 Correct 0 ms 3432 KB Output is correct
6 Correct 0 ms 3432 KB Output is correct
7 Correct 0 ms 3432 KB Output is correct
8 Correct 0 ms 3432 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 3432 KB Output is correct
2 Correct 0 ms 3432 KB Output is correct
3 Correct 4 ms 3432 KB Output is correct
4 Correct 4 ms 3432 KB Output is correct
5 Correct 4 ms 3432 KB Output is correct
6 Correct 4 ms 3432 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 32 ms 3432 KB Output is correct
2 Correct 32 ms 3432 KB Output is correct
3 Correct 28 ms 3432 KB Output is correct
4 Correct 28 ms 3432 KB Output is correct
5 Correct 28 ms 3432 KB Output is correct
6 Correct 24 ms 3432 KB Output is correct