Submission #673726

#TimeUsernameProblemLanguageResultExecution timeMemory
673726Hacv16Boxes with souvenirs (IOI15_boxes)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h>
using namespace std;

const int INF = 0x3f3f3f3f;

typedef long long ll;

ll getDist(ll x, ll y, ll l){
	if(y > x) swap(x, y);
	return min(x - y, l - x + y);
}

ll delivery(ll n, ll k, ll l, ll p[]){
	ll ans = 0;

	if(k == 1){
		for(int i = 0; i < n; i++)
			ans += getDist(0, p[i], l);

	}else if(k == n){
		ans = INF;
		ll mn = p[0], mx = p[n - 1];

		ans = min(ans, getDist(0, mx, l) + getDist(mx, mn, l) + getDist(mn, 0, l));
		ans = min(ans, getDist(0, mn, l) + getDist(mn, mx, l) + getDist(mx, 0, l));
	}

	return ans;
}

Compilation message (stderr)

/usr/bin/ld: /tmp/cc3h62xZ.o: in function `main':
grader.c:(.text.startup+0x1ef): undefined reference to `delivery(int, int, int, int*)'
collect2: error: ld returned 1 exit status