[Codeforces]1100A. Roman and Browser
題目來源: https://codeforces.com/problemset/problem/1100/A 這題單純地將間格以依序取出("+1總數"-間隔+1數量)-("-1總數"-間隔-1數量)的最大值 #pragma gcc optimize("o2") #include<bits/stdc++.h> #define IO ios_base::sync_with_stio(false) #define CI cin.tie(NULL) #define int long long int using namespace std; signed main() { int n,k,po = 0 ,ne = 0 , str [ 1005 ]; cin >> n >> k; int times = k; for ( int i = 1 ;i <= n;i ++ ) { cin >> str [i]; if ( str [i] == 1 ) po ++ ; else ne ++ ; } // cout << po << " " << ne << endl; int flag = 0 ,totalne[ 1005 ] = { 0 },totalpo[ 1005 ] = { 0 }; while (times -- ) { flag ++ ; for ( int i = flag;i <= n;i += k) { // cout << "i=" << i << endl; if ( str [i] ==- 1 ) total...