Submission #364028

#TimeUsernameProblemLanguageResultExecution timeMemory
364028wind_reaperBoxes with souvenirs (IOI15_boxes)C++17
0 / 100
1 ms512 KiB
#include "boxes.h"
#include <bits/stdc++.h>

using namespace std; 

#define dbg(x) cout << "[" << #x << ": " << x << "] ";

long long delivery(int N, int k, int L, int p[]) {
    vector<long long> pref(N+2), suf(N+2), x(N+2);
    x[0] = 0;
    for(int i = 1; i <= N; i++)
    	x[i] = (long long)p[i-1];

    x[N+1] = 1LL*L; 
    pref[0] = 0;
    for(int i = 1; i <= N + 1; i++)
    	pref[i] = (i > k ? pref[k*(i/k)]+x[k*(i/k)]+x[i] : x[i]);

    suf[N+1] = 0;
    for(int i = N; i >= 0; --i)
    	suf[i] = (N-i+1 > k ? suf[N-k*((N-i+1)/k)+1]+(L-x[N-k*((N-i+1)/k)+1])+L-x[i] : L-x[i]);
	
	long long ans = 1e18;

    for(int i = 0; i < N+1; i++)
    	ans = min(ans, pref[i] + suf[i+1] + L - x[i+1] + x[i]);

    return ans; 
}

Compilation message (stderr)

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:20:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   20 |     for(int i = N; i >= 0; --i)
      |     ^~~
boxes.cpp:23:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   23 |  long long ans = 1e18;
      |  ^~~~
#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...