답안 #739738

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
739738 2023-05-11T07:50:22 Z Toxtaq Feast (NOI19_feast) C++17
41 / 100
111 ms 262144 KB
#include<iostream>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<iomanip>
#include<random>
using namespace std;
int n;
vector<int>v;
vector<vector<vector<long long>>>table;
long long rec(int indx, int k, bool last){
	long long res=-1e15;
	if(k < 0)return -1e15;
	if(indx == n && k >= 0)return 0;
	if(indx == n)return -1e15;
	if(table[last][k][indx] != -1e18)return table[last][k][indx];
	if(last){
		res = max(rec(indx + 1, k, 1) + v[indx], rec(indx + 1, k,  0));
	}
	else{
		res = max(rec(indx+ 1, k - 1, 1) + v[indx], rec(indx + 1, k, 0));
	}
	return table[last][k][indx] = res;
}
int main()
{
	int k;
	cin >> n >> k;	
	v.resize(n);
	table.assign(2, vector<vector<long long>>(n, vector<long long>(n, -1e18)));
	for(int i = 0;i < n;++i){
		cin >> v[i];
	}
	cout << max(0LL, rec(0, k, 0));
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 111 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 109 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 108 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 424 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 428 KB Output is correct
9 Correct 0 ms 428 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 424 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 428 KB Output is correct
9 Correct 0 ms 428 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 2 ms 2260 KB Output is correct
12 Correct 2 ms 1876 KB Output is correct
13 Correct 2 ms 1836 KB Output is correct
14 Correct 2 ms 2004 KB Output is correct
15 Correct 2 ms 2004 KB Output is correct
16 Correct 2 ms 1836 KB Output is correct
17 Correct 2 ms 2132 KB Output is correct
18 Correct 1 ms 2004 KB Output is correct
19 Correct 2 ms 2004 KB Output is correct
20 Correct 1 ms 2260 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 424 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 428 KB Output is correct
9 Correct 0 ms 428 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 2 ms 2260 KB Output is correct
12 Correct 2 ms 1876 KB Output is correct
13 Correct 2 ms 1836 KB Output is correct
14 Correct 2 ms 2004 KB Output is correct
15 Correct 2 ms 2004 KB Output is correct
16 Correct 2 ms 1836 KB Output is correct
17 Correct 2 ms 2132 KB Output is correct
18 Correct 1 ms 2004 KB Output is correct
19 Correct 2 ms 2004 KB Output is correct
20 Correct 1 ms 2260 KB Output is correct
21 Correct 51 ms 89144 KB Output is correct
22 Correct 91 ms 88096 KB Output is correct
23 Correct 66 ms 89576 KB Output is correct
24 Correct 53 ms 89156 KB Output is correct
25 Correct 59 ms 94540 KB Output is correct
26 Correct 53 ms 93952 KB Output is correct
27 Correct 58 ms 94028 KB Output is correct
28 Correct 44 ms 93504 KB Output is correct
29 Correct 46 ms 91916 KB Output is correct
30 Correct 41 ms 88720 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 111 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -