Submission #124056

# Submission time Handle Problem Language Result Execution time Memory
124056 2019-07-02T12:34:05 Z tselmegkh Boxes with souvenirs (IOI15_boxes) C++14
0 / 100
15 ms 16120 KB
#include<bits/stdc++.h>
#include "boxes.h"
using namespace std;

//#define INF 1e18LL
#define MAX 1000005
#define xx first
#define yy second
#define pb push_back
#define mp make_pair
#define ull long long
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define nl '\n'
#define zai <<' '<<
#define all(a) a.begin(),a.end()
#define pc __builtin_popcount
#define debug(args...)  cerr << #args << " = "; Dbg,args; cerr << nl;
struct Dbg { template<typename T> Dbg& operator,(const T& v) { cerr << v << ", "; return *this; } } Dbg;
template <typename T> ostream& operator<<(ostream& _o_, const vector<T>& _v_){
if(!_v_.empty()){_o_<<'[';copy(_v_.begin(),_v_.end(),ostream_iterator<T>(_o_,", "));_o_<<"\b\b]";}return _o_;}
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
template<class C> void mini(C &_a, C _b) { _a = min(_a, _b); }
template<class C> void maxi(C &_a, C _b) { _a = max(_a, _b); }

ull dp[MAX][2];
const ull INF = 1e18;

ull delivery(int n, int k, int L, int pos[]){
    sort(pos, pos + n);
    ull ans = INF;
    memset(dp, 0x3f3f3f3f, sizeof dp);
    dp[0][0] = dp[0][1] = 0;
    for(int i = 1; i <= n; i++){
        mini(dp[i][0], dp[max(0, i - k)][0] + min(pos[i - 1] * 2, L));
    }
    reverse(pos, pos + n);
    for(int i = 1; i <= n; i--){
        mini(dp[i][1], dp[max(0, i - k)][1] + min((L - pos[i - 1])*2, L));
    }
    for(int i = 0; i <= n; i++){
        mini(ans, dp[i][0] + dp[n - i][1]);
        mini(ans, dp[i][1] + dp[n - i][0]);
    }
    return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 15 ms 15992 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 16120 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 15 ms 15992 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 15 ms 15992 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 15 ms 15992 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 15 ms 15992 KB Output isn't correct
2 Halted 0 ms 0 KB -