CodeForces 688A Opponents (水题)
Codeforces 水题
2023-09-11 14:17:19 时间
题意:给定 n 行数,让你找出连续最多的全是1的个数。
析:好像也没什么可说的,那就判断一下,并不断更新最大值呗。
代码如下:
#include <iostream> #include <cmath> #include <cstdlib> #include <set> #include <cstdio> #include <cstring> #include <algorithm> #include <string> using namespace std; typedef long long LL; string s; int main(){ int n, d, cnt = 0; bool ok = false; int m = -1; scanf("%d %d", &n, &d); for(int i = 0; i < d; ++i){ cin >> s; int j; for(j = 0; j < n; ++j) if(s[j] != '1') break; if(ok && j != n) ++cnt; else if(j != n){ ok = true; cnt = 1; } else{ cnt = 0; ok = false; } m = max(m ,cnt); } printf("%d\n", m); return 0; }
相关文章
- codeforces 391E2 (【Codeforces Rockethon 2014】E2)
- Codeforces Round #828 (Div. 3) E1 E2
- CodeForces 935E Fafa and Ancient Mathematics (树形DP)
- CodeForces 782B The Meeting Place Cannot Be Changed (二分)
- CodeForces 382C Arithmetic Progression (排序+分类讨论)
- CodeForces 731B Coupons and Discounts (水题模拟)
- CodeForces 723B Text Document Analysis (水题模拟)
- CodeForces 712C Memory and De-Evolution (贪心+暴力)
- CodeForces 709A Juicer (水题, 模拟)
- CodeForces 548A Mike and Fax (回文,水题)
- CodeForces 540A Combination Lock (水题)
- CodeForces 681B Economy Game (暴力)
- 【CodeForces 520E】Pluses everywhere
- 【CodeForces 614A】Link/Cut Tree
- 【CodeForces 624D/623B】Array GCD