Submission #1109793

#TimeUsernameProblemLanguageResultExecution timeMemory
1109793TsaganaSkyline (IZhO11_skyline)C++14
0 / 100
55 ms47892 KiB
#include<bits/stdc++.h> #define IOS ios_base::sync_with_stdio(false);cin.tie();cout.tie(); #define all(x) x.begin(), x.end() #define lnl long long #define pq priority_queue #define eb emplace_back #define lb lower_bound #define ub upper_bound #define pb push_back #define pp pop_back #define F first #define S second using namespace std; int antiloop = 0; int dp[301][201][201]; int a[301]; void solve () { int n; cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 1; i <= 300; i++) for (int j = 0; j <= 200; j++) for (int k = 0; k <= 200; k++) dp[i][j][k] = 1e9; for (int i = 0; i <= a[1]; i++) dp[2][a[1]-i][a[2]] = dp[1][0][a[1]-i] = i*3; for (int i = 2; i <= n; i++) { for (int j = a[i-1]; j >= 0; j--) for (int k = a[i]; k >= 0; k--) dp[i][j][k] = min(dp[i][j][k], dp[i][j][k+1]+3); for (int j = a[i-1]; j >= 0; j--) for (int k = a[i]; k >= 0; k--) dp[i][j][k] = min(dp[i][j][k], dp[i][j+1][k+1]+5); if (i != n) { for (int j = min({a[i-1], a[i], a[i+1]}); j >= 0; j--) for (int k = a[i]; k >= j; k--) dp[i+1][k-j][a[i+1]-j] = min(dp[i+1][k-j][a[i+1]-j], dp[i][j][k] + j*7); } } cout << dp[n][0][0]; } int main() {IOS solve(); return 0;}
#Verdict Execution timeMemoryGrader output
Fetching results...