提交时间:2023-11-25 09:33:17

运行 ID: 111971

#include <bits/stdc++.h> using namespace std; int a[1005]; int m[1005]; int n; int main() { cin >> n; for(int i = 1;i <= n;i++) cin >> m[i]; a[n] = m[n]; a[n - 1] = m[n - 1]; for(int i = n - 2;i >= 0;i--) a[i] = min(m[i] + a[i + 1] , a[i + 2] + m[i]); cout << min(a[0] , a[1]); return 0; }