Submission #364031

#TimeUsernameProblemLanguageResultExecution timeMemory
364031wind_reaperBoxes with souvenirs (IOI15_boxes)C++17
100 / 100
665 ms321004 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);
    //pref[i] -> min time to deliver everything 0....i and return to 0
    //suf[i] -> min time to deliver everything in i..N and return to N+1/0
    long long L = 1LL*l;
    x[0] = 0;
    for(int i = 1; i <= N; i++)
    	x[i] = (long long)p[i-1];

    x[N+1] = L; 
    for(int i = 1; i <= N + 1; i++)
    	pref[i] = (i > k ? pref[i-k] + min(2*x[i], L) : min(L, 2*x[i]));

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

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

    return ans; 
}

Compilation message (stderr)

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