Submission #219610

# Submission time Handle Problem Language Result Execution time Memory
219610 2020-04-05T18:03:39 Z summitwei Boxes with souvenirs (IOI15_boxes) C++17
0 / 100
5 ms 384 KB
#include <bits/stdc++.h>
#include <boxes.h>
using namespace std;
typedef vector<int> vi;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<ll> vll;
#define INF 1000000000000000000LL
#define MOD 1000000007LL
#define EPSILON 0.00001
#define f first
#define s second
#define pb push_back
#define mp make_pair

#define FOR(i, a, b) for (ll i=(a); i<=(signed)(b); i++)
#define F0R(i, a) for (ll i=0; i<(signed)(a); i++)
#define RFOR(i, a, b) for (ll i=(a); i >= b; i--)

#define MN 10000005
int n, k; ll l;
ll d[MN];
ll ps[MN];
ll rps[MN];

ll delivery(int n, int k, int l, int positions[]){
    ::n = n; ::k = k; ::l = (ll)l;
    F0R(i, n) d[i] = positions[i];
    F0R(i, n){
        ps[i] = d[i]*2;
        if(i >= k){
            ps[i] += ps[i-k];
        }
    }
    RFOR(i, n-1, 0){
        rps[i] = (l-d[i])*2;
        if(i+k < n){
            rps[i] += rps[i+k];
        }
    }
    ll ans = INF;
    F0R(i, n-1){
        ans = min(ans, ps[i]+rps[i+1]);
    }
    if(k >= n) ans = min(ans, ::l);
    else{
        F0R(i, n-k+1){
            int lf = i-1, rt = i+k;
            ll res = ::l+(lf<0?0:ps[lf])+(rt>=n?0:rps[rt]);
            ans = min(ans, res);
        }
    }
    return ans;
}

/*int main(){
    //ios_base::sync_with_stdio(false);
    //cin.tie(0);

    int N, K, L;
    cin >> N >> K >> L;
    int pos[N];
    F0R(i, N) cin >> pos[i];
    cout << delivery(N, K, L, pos) << "\n";
    
    return 0;
}*/

Compilation message

boxes.cpp: In function 'll delivery(int, int, int, int*)':
boxes.cpp:29:49: warning: declaration of 'l' shadows a global declaration [-Wshadow]
 ll delivery(int n, int k, int l, int positions[]){
                                                 ^
boxes.cpp:24:14: note: shadowed declaration is here
 int n, k; ll l;
              ^
boxes.cpp:29:49: warning: declaration of 'k' shadows a global declaration [-Wshadow]
 ll delivery(int n, int k, int l, int positions[]){
                                                 ^
boxes.cpp:24:8: note: shadowed declaration is here
 int n, k; ll l;
        ^
boxes.cpp:29:49: warning: declaration of 'n' shadows a global declaration [-Wshadow]
 ll delivery(int n, int k, int l, int positions[]){
                                                 ^
boxes.cpp:24:5: note: shadowed declaration is here
 int n, k; ll l;
     ^
boxes.cpp:51:23: warning: conversion to 'int' from 'll {aka long long int}' may alter its value [-Wconversion]
             int lf = i-1, rt = i+k;
                      ~^~
boxes.cpp:51:33: warning: conversion to 'int' from 'll {aka long long int}' may alter its value [-Wconversion]
             int lf = i-1, rt = i+k;
                                ~^~
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Incorrect 5 ms 384 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 5 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -