Submission #218487

# Submission time Handle Problem Language Result Execution time Memory
218487 2020-04-02T08:11:43 Z socho Boxes with souvenirs (IOI15_boxes) C++14
0 / 100
13 ms 16032 KB
#include "boxes.h"
#include "bits/stdc++.h"
using namespace std;
 
const long long MXN = 1000005;
long long n, k, l, h, pos[MXN], rpos[MXN];
long long dpleft[MXN];
long long dpright[MXN];
 
long long delivery(int N, int K, int L, int p[]) {
	for (int i=0; i<MXN; i++) {
		dpleft[i] = -1;
		dpright[i] = -1;
	}
	n = N;
	k = K;
	l = L;
	h = l/2;
	for (int i=0; i<n; i++) {
		pos[i] = p[i];
		rpos[i] = L - p[i];
	}
	long long best = LLONG_MAX;
	for (int i=0; i<n; i++) {
		dpleft[i] = pos[i] * 2;
		if (i - k >= 0) dpleft[i] += dpleft[i-k];
	}
	for (int i=n-1; i>=0; i--) {
		dpright[i] = rpos[i] * 2;
		if (i + k < n) dpright[i] += dpright[i+k];
	}
	for (int i=0; i<n; i++) cout << dpleft[i] << ' '; cout << endl;
	for (int i=0; i<n; i++) cout << dpright[i] << ' '; cout << endl;
	
	for (int i=0; i<n-1; i++) {
		best = min(best, dpleft[i] + dpright[i+1]);
	}
	for (int i=0; i<n-1; i++) {
		int unt = l;
		if (i >= 1) unt += dpleft[i-1];
		if (i + k < n - 1) unt += dpright[i+k+1];
	}
	
	return best;
	
}

Compilation message

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:28:14: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
  for (int i=n-1; i>=0; i--) {
             ~^~
boxes.cpp:32:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
  for (int i=0; i<n; i++) cout << dpleft[i] << ' '; cout << endl;
  ^~~
boxes.cpp:32:52: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  for (int i=0; i<n; i++) cout << dpleft[i] << ' '; cout << endl;
                                                    ^~~~
boxes.cpp:33:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
  for (int i=0; i<n; i++) cout << dpright[i] << ' '; cout << endl;
  ^~~
boxes.cpp:33:53: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  for (int i=0; i<n; i++) cout << dpright[i] << ' '; cout << endl;
                                                     ^~~~
boxes.cpp:39:13: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
   int unt = l;
             ^
boxes.cpp:40:19: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
   if (i >= 1) unt += dpleft[i-1];
               ~~~~^~~~~~~~~~~~~~
boxes.cpp:41:26: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
   if (i + k < n - 1) unt += dpright[i+k+1];
                      ~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 16032 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 16000 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 16000 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 16032 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 16032 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 16032 KB Output isn't correct
2 Halted 0 ms 0 KB -