'commit'
This commit is contained in:
26
TangDou/AcWing/MonotonicQueue/1087_BruteForce.cpp
Normal file
26
TangDou/AcWing/MonotonicQueue/1087_BruteForce.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
const int N = 100010;
|
||||
typedef long long ll;
|
||||
int a[N];
|
||||
ll s[N], f[N];
|
||||
|
||||
/*
|
||||
BruteForce
|
||||
通过了 9/12个数据
|
||||
*/
|
||||
int main() {
|
||||
int n, m;
|
||||
cin >> n >> m;
|
||||
for (int i = 1; i <= n; i++) cin >> s[i], s[i] += s[i - 1];
|
||||
|
||||
// 暴力大法
|
||||
for (int i = 1; i <= n; i++)
|
||||
for (int j = i; j >= i - m; j--)
|
||||
f[i] = max(f[i], f[j - 1] + s[i] - s[j]);
|
||||
|
||||
cout << f[n] << endl;
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user