Submission #638286

# Submission time Handle Problem Language Result Execution time Memory
638286 2022-09-05T08:13:18 Z shmad Feast (NOI19_feast) C++17
41 / 100
171 ms 143820 KB
#pragma GCC optimize("O3", "unroll-loops") // "Ofast" 	
#pragma GCC target("avx2", "bmi", "bmi2", "lzcnt", "popcnt") 

#include <bits/stdc++.h>

//#define int long long
#define vt vector
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define ff first
#define ss second
#define dbg(x) cerr << #x << " = " << x << '\n'
#define bit(x, i) ((x) >> (i) & 1)

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vvt = vt< vt<int> >;

const int N = 1e6 + 5, mod = 1e9 + 7, B = 500;
const ll inf = 1e18 + 7, LIM = (1ll << 60);
const double eps = 1e-6;

ll n, k, a[N], dp[2005][2005][2];
 
void solve () {
	cin >> n >> k;
	for (int i = 1; i <= n; i++) cin >> a[i];
		for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= k; j++) {
			dp[i][j][1] = max({dp[i - 1][j][1], dp[i - 1][j - 1][0], dp[i - 1][j - 1][1]}) + a[i];
			dp[i][j][0] = max(dp[i - 1][j][0], dp[i - 1][j][1]);
		}
	}
	cout << max(dp[n][k][0], dp[n][k][1]);
	cout << '\n';
}

bool testcases = 0;

signed main() {
#ifdef ONLINE_JUDGE
	freopen(".in", "r", stdin);
	freopen(".out", "w", stdout);
#endif
	cin.tie(0) -> sync_with_stdio(0);
	int test = 1;
	if (testcases) cin >> test;
	for (int cs = 1; cs <= test; cs++) {
		solve();
	}
}
# Verdict Execution time Memory Grader output
1 Runtime error 171 ms 143820 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 50 ms 23048 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 60 ms 23140 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 596 KB Output is correct
2 Correct 1 ms 724 KB Output is correct
3 Correct 1 ms 596 KB Output is correct
4 Correct 1 ms 720 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 1 ms 592 KB Output is correct
7 Correct 1 ms 596 KB Output is correct
8 Correct 1 ms 596 KB Output is correct
9 Correct 1 ms 592 KB Output is correct
10 Correct 1 ms 580 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 596 KB Output is correct
2 Correct 1 ms 724 KB Output is correct
3 Correct 1 ms 596 KB Output is correct
4 Correct 1 ms 720 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 1 ms 592 KB Output is correct
7 Correct 1 ms 596 KB Output is correct
8 Correct 1 ms 596 KB Output is correct
9 Correct 1 ms 592 KB Output is correct
10 Correct 1 ms 580 KB Output is correct
11 Correct 1 ms 1620 KB Output is correct
12 Correct 1 ms 1620 KB Output is correct
13 Correct 1 ms 1492 KB Output is correct
14 Correct 1 ms 1620 KB Output is correct
15 Correct 1 ms 1492 KB Output is correct
16 Correct 1 ms 1492 KB Output is correct
17 Correct 1 ms 1608 KB Output is correct
18 Correct 1 ms 1356 KB Output is correct
19 Correct 1 ms 1492 KB Output is correct
20 Correct 1 ms 1484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 596 KB Output is correct
2 Correct 1 ms 724 KB Output is correct
3 Correct 1 ms 596 KB Output is correct
4 Correct 1 ms 720 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 1 ms 592 KB Output is correct
7 Correct 1 ms 596 KB Output is correct
8 Correct 1 ms 596 KB Output is correct
9 Correct 1 ms 592 KB Output is correct
10 Correct 1 ms 580 KB Output is correct
11 Correct 1 ms 1620 KB Output is correct
12 Correct 1 ms 1620 KB Output is correct
13 Correct 1 ms 1492 KB Output is correct
14 Correct 1 ms 1620 KB Output is correct
15 Correct 1 ms 1492 KB Output is correct
16 Correct 1 ms 1492 KB Output is correct
17 Correct 1 ms 1608 KB Output is correct
18 Correct 1 ms 1356 KB Output is correct
19 Correct 1 ms 1492 KB Output is correct
20 Correct 1 ms 1484 KB Output is correct
21 Correct 7 ms 14292 KB Output is correct
22 Correct 28 ms 59092 KB Output is correct
23 Correct 13 ms 19924 KB Output is correct
24 Correct 10 ms 14676 KB Output is correct
25 Correct 9 ms 17512 KB Output is correct
26 Correct 8 ms 13780 KB Output is correct
27 Correct 8 ms 16980 KB Output is correct
28 Correct 5 ms 9308 KB Output is correct
29 Correct 5 ms 9200 KB Output is correct
30 Correct 5 ms 8276 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 171 ms 143820 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -