Submission #947961

# Submission time Handle Problem Language Result Execution time Memory
947961 2024-03-17T10:09:41 Z steveonalex Boxes with souvenirs (IOI15_boxes) C++11
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "boxes.h"
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define MASK(i) (1ULL << (i))
#define GETBIT(mask, i) (((mask) >> (i)) & 1)
#define ALL(v) (v).begin(), (v).end()
 
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
 
ll LASTBIT(ll mask){return (mask) & (-mask);}
int pop_cnt(ll mask){return __builtin_popcountll(mask);}
int ctz(ll mask){return __builtin_ctzll(mask);}
int logOf(ll mask){return 63 - __builtin_clzll(mask);}
 
mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
ll rngesus(ll l, ll r){return l + (ull) rng() % (r - l + 1);}
 
template <class T1, class T2>
    bool maximize(T1 &a, T2 b){
        if (a < b) {a = b; return true;}
        return false;
    }
 
template <class T1, class T2>
    bool minimize(T1 &a, T2 b){
        if (a > b) {a = b; return true;}
        return false;
    }
 
template <class T>
    void printArr(T& container, string separator = " ", string finish = "\n", ostream &out = cout){
        for(auto item: container) out << item << separator;
        out << finish;
    }
 
template <class T>
    void remove_dup(vector<T> &a){
        sort(ALL(a));
        a.resize(unique(ALL(a)) - a.begin());
    }

ll delivery(int n, int k, int L, int p[]) {
    vector<int> a;
    for(int i = 0; i<n; ++i) a.push_back(p[i]);

    ll ans = 0;
    for(int i = 0; i<n; i += k){
        int l = i, r = min(i + k - 1, n - 1);
        ll cur = min({a[r] * 2, L, (L - a[l]) * 2});
        if (a[l] <= L / 2 && a[r] > L / 2){
            int idx = -1;
            for(int j = l; j <= r; ++j) if (a[j] <= L / 2) maximize(idx, j);
            minimize(cur, a[j] * 2 + (L - a[j+1]) * 2);
        }
        ans += cur;
    }
    return ans;
}

 
// int main(void){
//     ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

 
//     return 0;
// }

Compilation message

boxes.cpp: In function 'll delivery(int, int, int, int*)':
boxes.cpp:59:29: error: 'j' was not declared in this scope
   59 |             minimize(cur, a[j] * 2 + (L - a[j+1]) * 2);
      |                             ^