Submission #142840

# Submission time Handle Problem Language Result Execution time Memory
142840 2019-08-11T12:11:54 Z daniel920712 Boxes with souvenirs (IOI15_boxes) C++14
10 / 100
2 ms 376 KB
#include "boxes.h"
#include <stdio.h>
#include <iostream>

using namespace std;
bool have[10000005]={0};
long long delivery(int N, int K, int L, int p[])
{
    long long ans=0;
    int i,l=1e9+7,r=-1,j;
    for(i=0;i<N;i++)
    {
        if(p[i]<=L/2)
        {
            if((i+1)%K==0)
            {
                ans+=p[i]*2;
                for(j=i-K+1;j<=i;j++) have[j]=1;
                //printf("%lld\n",ans);
            }
        }
        else break;
    }
    for(i=N-1;i>=0;i--)
    {
        if(p[i]>L/2)
        {
            if((N-i)%K==0)
            {
                ans+=(L-p[i])*2;
                for(j=i;j-i<K;j++) have[j]=1;
                //printf("%lld\n",ans);
            }
        }
        else break;
    }
    for(j=0;j<N;j++)
    {
        if(have[j]==0)
        {
            l=min(l,j);
            r=max(r,j);
        }
    }
    if(r!=-1)
    {
        ans+=L;
        if((r-l)>=K) ans+=min(min(p[l+K]*2,(L-p[l+K]*2)),min(p[r-K]*2,(L-p[r-K]*2)));
    }

    return ans;

}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Incorrect 2 ms 344 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Incorrect 2 ms 256 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Incorrect 2 ms 344 KB Output isn't correct
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Incorrect 2 ms 344 KB Output isn't correct
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Incorrect 2 ms 344 KB Output isn't correct
13 Halted 0 ms 0 KB -