Submission #128185

#TimeUsernameProblemLanguageResultExecution timeMemory
128185zeyad49Boxes with souvenirs (IOI15_boxes)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; const int N=1000; const long long INF=(long)1e18; int K,L; 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=INF; int last; last=max(r, l+K-1); ans=dp(last+1,r)+2*teams[last]; last=min(l, r-K+1); ans=min(ans, dp(l,last-1)+2*(L-teams[last])); return memo[l][r]=ans; } long long delivery(int a, int b, int c, int x[]) { K=b; long long ans=0; L=c; sort(x,x+a); for(int i=0;i<a;i++){ teams[i]=x[i]; ans+=min(x[i],L-x[i]); for(int j=0;j<a;j++) memo[i][j]=-1; } return 2*ans; } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(NULL); int a,b,c; cin>>a>>b>>c; int z[a]; for(int i=0;i<a;i++) cin>>z[i]; cout<<delivery(a,b,c,z); }

Compilation message (stderr)

boxes.cpp: In function 'long long int dp(int, int)':
boxes.cpp:20:21: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
   return memo[l][r]=ans;
                     ^~~
/tmp/ccOb46tm.o: In function `main':
grader.c:(.text.startup+0x0): multiple definition of `main'
/tmp/cchsyMtv.o:boxes.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status