Submission #1156225

#TimeUsernameProblemLanguageResultExecution timeMemory
1156225brianhdzmdo선물상자 (IOI15_boxes)C++20
Compilation error
0 ms0 KiB
#include <algorithm>
#include <cmath>
#include <iostream>
#include <deque>
#include <math.h>
#include <numeric>
#include <set>
#include <stack>
#include <map>
#include <string>
#include <utility>
#include <vector>
#include <climits>

#define all(a) (a).begin(), (a).end()
#define allr(a) (a).rbegin(), (a).rend()
#define ll long long
#define ld long double
#define fr(i, a, b) for (ll i = a; i < b; i++)
#define fr1(i, a, b) for (ll i = a - 1; i >= b; i--)
#define fi first
#define se second
#define mp(j, k) make_pair(j, k)
#define pb(x) push_back(x)
#define in(x) insert(x)
#define vec vector<ll>
#define vecv vector<vector<ll> >
#define veb vector<bool>
#define vecp vector<pair<ll,ll>>
#define yes cout << "YES\n";
#define no cout << "NO\n";
#define ac 1e-7
#define fauto(a)   \
  for (auto i : a) \
    cout << i << " ";
#define fautop(a)  \
  for (auto i : a) \
    cout << i.fi << " " << i.se << endl;

const ll INF = 1e9;

using namespace std;

ll delivery(ll N, ll K, ll L, vec positions)
{
    multiset<ll> mst;

    fr(i, 0, positions.size())
    {
        if(positions[i] != 0)
            mst.insert(positions[i]);
        else
            N--;
    }
    
    ll cost = 1;
    ll curK = K;

    fr(i, 1, L)
    {
        cost++;
        if(N == 0)
        {
            cost += min(i, L - i);
            break;
        }
        ll ax = mst.count(i);
        if(ax)
        {
            if(ax < curK)
            {
                curK -= ax;
            }
            else
            {
                ax -= curK;
                N -= curK;
                ll dist = min(i, L - i) * 2;
                if(ax % K == 0)
                {
                    cost += dist * (ax / K + 1);
                    curK = K;
                }
                else
                {
                    cost += dist * (ax / K + 1);
                    curK = ax % K;
                }
            } 
        }
    }

    return cost;
}

Compilation message (stderr)

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