Submission #183879

#TimeUsernameProblemLanguageResultExecution timeMemory
183879mohammadBoxes with souvenirs (IOI15_boxes)C++14
10 / 100
5 ms376 KiB
/* ░░░░██████████████████ ░░▄███████▀▀▀▀▀▀███████▄ ░▐████▀▒mohammad▒▀██████▄ ░███▀▒▒▒▒alaa▒▒▒▒▒▒▀█████ ░▐██▒▒▒alwrawrah▒▒▒▒▒████▌ ░▐█▌▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████▌ ░░█▒▄▀▀▀▀▀▄▒▒▄▀▀▀▀▀▄▒▐███▌ ░░░▐░░░▄▄░░▌▐░░░▄▄░░▌▐███▌ ░▄▀▌░░░▀▀░░▌▐░░░▀▀░░▌▒▀▒█▌ ░▌▒▀▄░░░░▄▀▒▒▀▄░░░▄▀▒▒▄▀▒▌ ░▀▄▐▒▀▀▀▀▒▒▒▒▒▒▀▀▀▒▒▒▒▒▒█ ░░░▀▌▒▄██▄▄▄▄████▄▒▒▒▒█▀ ░░░░▄██████████████▒▒▐▌ ░░░▀███▀▀████▀█████▀▒▌ ░░░░░▌▒▒▒▄▒▒▒▄▒▒▒▒▒▒▐ ░░░░░▌▒▒▒▒▀▀▀▒▒▒▒▒▒▒▐ */ #include<bits/stdc++.h> #include "boxes.h" using namespace std; typedef long long ll ; const ll oo = 1e13 ; const double PI = acos(-1) ; const ll M = 1e9 + 7 ; ll dp[10000001] , a[10000001] , ans = 1e18; ll delivery(int N, int K, int L, int p[]){ for(int i = 0 ; i < N ; ++i){ if(i + 1 >= K) dp[i] = (ll)(p[i] + min(p[i] , L - p[i]) + (i + 1 == K ? 0 : dp[i - K])); else dp[i] = p[i] * 2; } for(int i = N - 1; i >= 0 ; --i){ if(N - i >= K) a[i] = (ll)((L - p[i]) + min(p[i] , L - p[i]) + a[i + K]); else a[i] = p[i] * 2; } for(int i = 1 ; i < K - 1 ; ++i) dp[i] += dp[i - 1]; for(int i = N - 2 ; i >= N - K ; --i) a[i] += a[i + 1]; for(int i = 0 ; i < N - 1 ; ++i) ans = min(dp[i] + a[i + 1] , ans); return min(ans , min(dp[N - 1] , a[0])); }
#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...