Submission #128313

# Submission time Handle Problem Language Result Execution time Memory
128313 2019-07-10T16:35:44 Z zeyad49 Boxes with souvenirs (IOI15_boxes) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
const int N=1000;
const long long INF=(long)1e18;
int K,L,n;
int memo[N][N];
int teams[N];
long long dist[N][N];
long long dp(int l,int r) {
		if(l>r)
			return 0;
		if(memo[l][r]!=-1)
		    return memo[l][r];
		long long ans=K==n?L:INF;
		
		for(int k=l,it=1;k<=r && it<=K;k++,it++){
		    
		    ans=min(ans,2*teams[k]+dp(k+1,r));
		}
		for(int k=r,it=1;k>=l && it<=K;k--;it++){
		    ans=min(ans,2*(L-teams[k])+dp(l,k-1));
		}
		return memo[l][r]=ans;
	}
	long long delivery(int a, int b, int c, int x[]) {
		K=b;
		L=c;
		n=a;
		sort(x,x+a);
		for(int i=0;i<a;i++){
		    teams[i]=x[i];
        for(int j=0;j<a;j++)
		        memo[i][j]=-1;
		}
	
		return dp(0,a-1);
	}

Compilation message

boxes.cpp: In function 'long long int dp(int, int)':
boxes.cpp:20:37: error: expected ')' before ';' token
   for(int k=r,it=1;k>=l && it<=K;k--;it++){
                                     ^
boxes.cpp:20:3: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   for(int k=r,it=1;k>=l && it<=K;k--;it++){
   ^~~
boxes.cpp:20:38: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   for(int k=r,it=1;k>=l && it<=K;k--;it++){
                                      ^~
boxes.cpp:20:38: error: 'it' was not declared in this scope
boxes.cpp:20:38: note: suggested alternative: 'int'
   for(int k=r,it=1;k>=l && it<=K;k--;it++){
                                      ^~
                                      int
boxes.cpp:23:21: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
   return memo[l][r]=ans;
                     ^~~