日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

贪心 Codeforces Round #191 (Div. 2) A. Flipping Game

發布時間:2025/7/14 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 贪心 Codeforces Round #191 (Div. 2) A. Flipping Game 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

?

題目傳送門

1 /* 2 貪心:暴力貪心水水 3 */ 4 #include <cstdio> 5 #include <algorithm> 6 #include <cstring> 7 using namespace std; 8 9 const int MAXN = 1e2 + 10; 10 const int INF = 0x3f3f3f3f; 11 int a[MAXN]; 12 13 int main(void) //Codeforces Round #191 (Div. 2) A. Flipping Game 14 { 15 int n; scanf ("%d", &n); 16 int sum = 0; 17 for (int i=1; i<=n; ++i) scanf ("%d", &a[i]), sum += a[i]; 18 19 int ans = 0; 20 for (int i=1; i<=n; ++i) 21 { 22 for (int j=1; j<=n-i+1; ++j) 23 { 24 int pre = 0; int now = 0; 25 for (int k=j; k<=j+i-1; ++k) 26 { 27 pre += a[k]; now += 1 - a[k]; 28 } 29 ans = max (ans, sum - pre + now); 30 } 31 } 32 33 printf ("%d\n", ans); 34 35 36 return 0; 37 }

?

轉載于:https://www.cnblogs.com/Running-Time/p/4657346.html

總結

以上是生活随笔為你收集整理的贪心 Codeforces Round #191 (Div. 2) A. Flipping Game的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。