Submission #446935

#TimeUsernameProblemLanguageResultExecution timeMemory
446935JerryLiu06선물상자 (IOI15_boxes)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>

#include "boxes.h"
 
using namespace std;
 
using ll = long long;
using ld = long double;
using db = double;
using str = string;
 
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using pd = pair<db, db>;
 
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<ll>;
using vd = vector<db>;
using vs = vector<str>;
using vpi = vector<pi>;
using vpl = vector<pl>;
using vpd = vector<pd>;
 
#define mp make_pair
#define f first
#define s second
 
#define sz(x) (int)(x).size()
#define bg(x) begin(x)
#define all(x) bg(x), end(x)
#define sor(x) sort(all(x))
#define rsz resize
#define ins insert 
#define ft front()
#define bk back()
#define pb push_back
#define pf push_front
 
#define lb lower_bound
#define ub upper_bound
 
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (int i = (b) - 1; i >= (a); i--)
#define R0F(i, a) ROF(i, 0, a)
#define EACH(a, x) for (auto& a : x)
 
ll cdiv(ll a, ll b) { return a / b + ((a ^ b) > 0 && a % b); }
ll fdiv(ll a, ll b) { return a / b - ((a ^ b) < 0 && a % b); }
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
template<class T> void remDup(vector<T>& v) { sor(v); v.erase(unique(all(v)), v.end()); }
 
const int MOD = 1e9 + 7;
const int MX = 1e6 + 10;
const ll INF = 1e18;

ll delivery(int N, int K, int L, vi positions) {
    int mid = ub(all(positions), L / 2) - positions.bg(); ll DP[N + 2];

    FOR(i, 1, mid + 1) { DP[i] = 2 * positions[i - 1]; if (i >= K) DP[i] += DP[i - K]; }
    ROF(i, mid + 1, N + 1) { DP[i] = 2 * (L - positions[i - 1]); if (i + K <= N) DP[i] += DP[i + K]; }

    ll ans = DP[mid] + DP[mid + 1]; FOR(i, mid - K + 2, mid + 1) {
        ckmin(ans, L + DP[max(i - 1, 0)] + DP[min(i + K, N + 1)]);
    }
    return ans;
}

Compilation message (stderr)

boxes.cpp: In function 'll delivery(int, int, int, vi)':
boxes.cpp:62:41: warning: conversion from '__gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type' {aka 'long int'} to 'int' may change value [-Wconversion]
   62 |     int mid = ub(all(positions), L / 2) - positions.bg(); ll DP[N + 2];
      |                                         ^
/usr/bin/ld: /tmp/ccBnfEFt.o: in function `main':
grader.c:(.text.startup+0x1ef): undefined reference to `delivery(int, int, int, int*)'
collect2: error: ld returned 1 exit status