Submission #437782

#TimeUsernameProblemLanguageResultExecution timeMemory
437782hhhhauraBoxes with souvenirs (IOI15_boxes)C++14
50 / 100
2080 ms37304 KiB
#define wiwihorz #include <bits/stdc++.h> #pragma GCC optimize("Ofast") #pragma loop-opt(on) #define rep(i, a, b) for(int i = a; i <= b; i ++) #define rrep(i, a, b) for(int i = b; i >= a; i--) #define ceil(a, b) ((a + b - 1) / (b)) #define all(x) x.begin(), x.end() #define INF 1000000000000000000 #define MOD 1000000007 #define eps (1e-9) using namespace std; #define ll long long int #define lld long double #define pii pair<int, int> #define random mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()) #ifdef wiwihorz #define print(a...) cerr << "line " << __LINE__ << ": ", kout("[" + string(#a) + "] = ", a) void vprint(auto L, auto R) { while(L < R) cerr << *L << " \n"[next(L) == R], ++L;} void kout() { cerr << endl; } template<class T1, class ... T2> void kout(T1 a, T2 ... e) { cerr << a << " ", kout(e...);} #else #define print(...) 0 #define vprint(...) 0 #endif #include "boxes.h" int n, k, l; vector<ll> pos, dp1, dp2; void init_(int _n, int _k, int _l) { n = _n, k = _k, l = _l; pos.assign(n + 1, 0); dp1.assign(n + 1, INF); dp2.assign(n + 1, INF); } ll solve() { dp1[0] = 0, dp2[0] = 0; rep(i, 1, n) { rep(j, 1, k) { if(i - j >= 0) dp1[i] = min(dp1[i], dp1[i - j] + 2 * pos[i]); if(i - j >= 0) dp2[i] = min(dp2[i], dp2[i - j] + 2 * (l - pos[n - i + 1])); } } ll ans = INF; rep(i, 0, n) rep(j, i, n) { ll cur = dp1[i] + ceil(j - i, k) * (ll)l + dp2[n - j]; ans = min(ans, cur); } return ans; } ll delivery(int N, int K, int L, int p[]) { init_(N, K, L); rep(i, 0, N - 1) pos[i + 1] = p[i]; return solve(); }

Compilation message (stderr)

boxes.cpp:4: warning: ignoring '#pragma loop ' [-Wunknown-pragmas]
    4 | #pragma loop-opt(on)
      | 
boxes.cpp:24:13: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   24 | void vprint(auto L, auto R) { while(L < R) cerr << *L << " \n"[next(L) == R], ++L;}
      |             ^~~~
boxes.cpp:24:21: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   24 | void vprint(auto L, auto R) { while(L < R) cerr << *L << " \n"[next(L) == R], ++L;}
      |                     ^~~~
#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...