Submission #1218545

#TimeUsernameProblemLanguageResultExecution timeMemory
1218545LIABoxes with souvenirs (IOI15_boxes)C++17
100 / 100
839 ms431044 KiB
#include "boxes.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef tuple <ll,ll,ll> plll;
typedef vector <plll> vplll;
typedef pair <ll,ll> pll;
typedef vector <ll> vll;
typedef vector <pll> vpll;
typedef vector <vector <pll>> vvpll;
typedef vector <vector <ll>> vvll;
typedef vector <bool> vb;
typedef vector <vector <bool>> vvb;
#define loop(i, s, e) for (ll i = (s); i < (e); ++i)
#define loopr(i, e, s) for (ll i = (e)-1; i >= (s); --i)
#define all(a) a.begin(), a.end()
const ll inf = 1e20;
ll n,k,l;
vll p;
vll r;
long long delivery(int N, int K, int L, int P[]) {
    n=N,k=K,l=L;
    p.resize(n);
    r.resize(n);
    loop(i,0,n) {
        p[i] = P[i];
        r[i] = l-P[i];
    }
    sort(all(p));
    sort(all(r));
    vll suml(n), sumr(n);

    for (ll i = 0; i < n; ++i) {
        suml[i] =p[i] + min(p[i], l-p[i]);
        if (i >= k)
            suml[i] += suml[i - k];
    }

    for (ll i = 0; i < n; ++i) {
        sumr[i] = r[i] + min(r[i], l-r[i]);
        if (i >= k)
            sumr[i] += sumr[i - k];
    }

    ll ans = inf;
    reverse(all(sumr));
    suml.push_back(0);
    sumr.push_back(0);
    loop(i,0,n) {
        ans = min(ans, suml[i] + sumr[i+1]);
    }
    ans = min(ans, sumr[0]);
    return ans;
}

Compilation message (stderr)

boxes.cpp:17:16: warning: overflow in conversion from 'double' to 'll' {aka 'long long int'} changes value from '1.0e+20' to '9223372036854775807' [-Woverflow]
   17 | const ll inf = 1e20;
      |                ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...