Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
水#include <cstdio> #include <climits> #include <algorithm> #define MAXN 30005 using std::min; int n, d[MAXN], dp[MAXN][3]; int main(int argc,char *argv[]) { scanf("%d", &n); for (int i = 1;i <= n;++i) scanf("%d", &d[i]); for (int i = 1;i <= n;++i) { dp[i][1] = dp[i - 1][1] + (d[i] != 1); dp[i][2] = min(dp[i - 1][1], dp[i - 1][2]) + (d[i] != 2); } printf("%d\n", min(dp[n][1], dp[n][2])); } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator