Submission #105179

# Submission time Handle Problem Language Result Execution time Memory
105179 2019-04-10T22:26:52 Z ly20 Boxes with souvenirs (IOI15_boxes) C++14
100 / 100
697 ms 333304 KB
#include<bits/stdc++.h>
using namespace std;
#define debug(args...) //fprintf(stderr,args)
const int MAXN=11234567;
long long ida[MAXN],volta[MAXN];
int vlt[MAXN];
long long delivery(int n1,int k1,int l1,int id[])
{
	long long n=n1,k=k1,l=l1;
	long long resp=MAXN*1123456789LL;
	for(int i=n-1;i>=0;i--)
	{
		vlt[n-i-1]=id[i];
	}
	for(int i=0;i<n;i++)
	{
		long long p=2*id[i];
		if(p>l)p=l;
		if(i<k)ida[i]=p;
		else ida[i]=ida[i-k]+p;
		debug("ida[%d]=%lld\n",i,ida[i]);
	}
	for(int i=0;i<n;i++)
	{
		long long p=2*(l-vlt[i]);
		if(p>l)p=l;
		if(i<k)volta[i]=p;
		else volta[i]=volta[i-k]+p;
		debug("vlt[%d]=%lld\n",i,volta[i]);
	}
	resp=min(resp,min(volta[n-1],ida[n-1]));
	for(int i=0;i<n-1;i++)
	{
		int v=n-i-2;
		debug("ida=%d volta=%d\n",i,v);
		resp=min(resp,ida[i]+volta[v]);
	}
	return resp;
}
/*int ps[MAXN];
int main()
{
	int n,k,l;
	scanf("%d %d %d",&n,&k,&l);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&ps[i]);
	}
	printf("%lld\n",delivery(n,k,l,ps));
}*/

Compilation message

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:11:13: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
  for(int i=n-1;i>=0;i--)
            ~^~
boxes.cpp:34:12: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
   int v=n-i-2;
         ~~~^~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 2 ms 384 KB Output is correct
22 Correct 2 ms 384 KB Output is correct
23 Correct 2 ms 384 KB Output is correct
24 Correct 2 ms 384 KB Output is correct
25 Correct 2 ms 384 KB Output is correct
26 Correct 2 ms 384 KB Output is correct
27 Correct 3 ms 384 KB Output is correct
28 Correct 2 ms 384 KB Output is correct
29 Correct 2 ms 384 KB Output is correct
30 Correct 3 ms 384 KB Output is correct
31 Correct 3 ms 384 KB Output is correct
32 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 2 ms 384 KB Output is correct
22 Correct 2 ms 384 KB Output is correct
23 Correct 2 ms 384 KB Output is correct
24 Correct 2 ms 384 KB Output is correct
25 Correct 2 ms 384 KB Output is correct
26 Correct 2 ms 384 KB Output is correct
27 Correct 3 ms 384 KB Output is correct
28 Correct 2 ms 384 KB Output is correct
29 Correct 2 ms 384 KB Output is correct
30 Correct 3 ms 384 KB Output is correct
31 Correct 3 ms 384 KB Output is correct
32 Correct 2 ms 384 KB Output is correct
33 Correct 63 ms 33496 KB Output is correct
34 Correct 30 ms 25848 KB Output is correct
35 Correct 30 ms 26232 KB Output is correct
36 Correct 58 ms 33676 KB Output is correct
37 Correct 55 ms 33656 KB Output is correct
38 Correct 59 ms 33656 KB Output is correct
39 Correct 58 ms 32120 KB Output is correct
40 Correct 39 ms 27648 KB Output is correct
41 Correct 64 ms 33612 KB Output is correct
42 Correct 39 ms 27808 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 2 ms 384 KB Output is correct
22 Correct 2 ms 384 KB Output is correct
23 Correct 2 ms 384 KB Output is correct
24 Correct 2 ms 384 KB Output is correct
25 Correct 2 ms 384 KB Output is correct
26 Correct 2 ms 384 KB Output is correct
27 Correct 3 ms 384 KB Output is correct
28 Correct 2 ms 384 KB Output is correct
29 Correct 2 ms 384 KB Output is correct
30 Correct 3 ms 384 KB Output is correct
31 Correct 3 ms 384 KB Output is correct
32 Correct 2 ms 384 KB Output is correct
33 Correct 63 ms 33496 KB Output is correct
34 Correct 30 ms 25848 KB Output is correct
35 Correct 30 ms 26232 KB Output is correct
36 Correct 58 ms 33676 KB Output is correct
37 Correct 55 ms 33656 KB Output is correct
38 Correct 59 ms 33656 KB Output is correct
39 Correct 58 ms 32120 KB Output is correct
40 Correct 39 ms 27648 KB Output is correct
41 Correct 64 ms 33612 KB Output is correct
42 Correct 39 ms 27808 KB Output is correct
43 Correct 656 ms 332012 KB Output is correct
44 Correct 278 ms 254840 KB Output is correct
45 Correct 345 ms 262744 KB Output is correct
46 Correct 697 ms 333020 KB Output is correct
47 Correct 605 ms 333068 KB Output is correct
48 Correct 625 ms 333156 KB Output is correct
49 Correct 546 ms 317924 KB Output is correct
50 Correct 346 ms 271864 KB Output is correct
51 Correct 545 ms 333304 KB Output is correct
52 Correct 377 ms 274392 KB Output is correct