Submission #1005977

# Submission time Handle Problem Language Result Execution time Memory
1005977 2024-06-23T09:54:36 Z Ludissey Boxes with souvenirs (IOI15_boxes) C++14
0 / 100
1 ms 604 KB
#include "boxes.h"
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
int N,K,L;

int clst(int x){
    if(x>L/2) x=L-x;
    return (x)*2;
}

long long delivery(signed _n, signed _k, signed _l, signed p[]) {
    N=_n;
    K=_k;
    L=_l;
    vector<int> a(N);
    vector<int> marked(N);
    for (int i = 0; i < N; i++) a[i]=p[i];
    sort(a.begin(),a.end());
    int sumFULL=1e9;
    int sumNOTFULL=0;
    int lmt=N;
    vector<pair<int,int>> res;
    vector<int> res2;
    vector<int> res3;
    for (int i = 0; i < N; i++) { res.push_back({abs(L-2*a[i]),i}); }
    sort(all(res));
    for (int i = 0; i < sz(res); i++)
    {
        if(i<K) res3.push_back(res[i].second);
        else {
            res3.push_back(res[i].second);
            res2.push_back(res[i].second);
        }
    }
    sort(all(res2));
    sort(all(res3));
    vector<int> prf1(sz(res2));
    lmt=sz(a);
    for (int i = 0; i < sz(a); i++) { if(a[i]>L/2) { lmt=i; break; } }
    for (int i = 0; i < lmt; i++) {
        if(i<K) prf1[i]=a[i]*2;
        else prf1[i]=a[i]*2+prf1[i-K];
    }
    for (int i = lmt; i < sz(res2); i--) {
        if(i<lmt+K) prf1[i]=(L-a[i])*2;
        else prf1[i]=(L-a[i])*2+prf1[i-K];
    }
    for (int i = max(0LL,lmt-K); i <= min(sz(a)-1,K+lmt); i++) sumFULL=min(sumFULL, L+prf1[i]+prf1[i+K]);

    for (int i = lmt-1; i >= 0; i-=K) sumNOTFULL+=a[i]*2;
    for (int i = lmt; i < sz(a); i+=K) sumNOTFULL+=(L-a[i])*2;
    return min(sumFULL,sumNOTFULL);
}
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 348 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -