Submission #1265734

#TimeUsernameProblemLanguageResultExecution timeMemory
1265734bangchanBoxes with souvenirs (IOI15_boxes)C++20
0 / 100
0 ms328 KiB
#include "boxes.h"
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <limits.h>
#include <set>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef map<int, int> mii;
typedef vector<vl> vvl;
typedef pair<ll, ll> pll;
typedef vector<pll> vpl;

#define F first
#define S second
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define pb push_back
#define forn(i, x, n) for (ll i = x; i < n; i++)
#define fornl(i, x, n) for(ll i = x; i >= n; i++)
#define all(x) x.begin(), x.end()
#define mod 1000000007
#define inf 10000000000000

long long delivery(int n, int k, int l, int p[]) {
    vl x;
    set<ll> st;

    x.pb(0); x.pb(l);
    st.insert(0); st.insert(l);
    forn(i, 0, n){ 
        ll c = st.size();
        st.insert(p[i]);
        if(st.size() > c) x.pb(p[i]);
    }

    sort(all(x));

    ll mint = l;
    forn(i, 0, x.size() - 1){
        mint = min(mint, 2 * (ll(l) - (ll(p[i + 1]) - ll(p[i]))));
    }
    
    return mint;

    /*int ans = 0, t = 0, tt = 0;
    forn(i, 0, n){
       t += max(t, p[i]);
       tt += min(tt, p[i]);
    }
    ans = min(t, tt);
    return ans * 2;*/
}
#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...