Submission #848128

# Submission time Handle Problem Language Result Execution time Memory
848128 2023-09-11T12:13:23 Z nguyennh Feast (NOI19_feast) C++14
0 / 100
11 ms 2136 KB
#include<bits/stdc++.h>
#define el '\n'
#define int long long
using namespace std ;

const int MN = 1e5 + 10 ;
const int N = 1005;
const int mod = 1e9 + 7;

mt19937 rd(chrono::steady_clock::now().time_since_epoch().count());

int Rand(int l, int h){
    return l + (1LL * rd() * rd() % (h - l + 1) + (h - l + 1)) % (h - l + 1);
}

inline void add(int &x , int val){
	if ( (x += val) >= mod ) x -= mod;
}

int a[MN] , n , k;
int dp[3000][3000];

signed main (){
//	freopen("FEAS.INP", "r", stdin);
//	freopen("FEAS.OUT", "w", stdout);
	ios_base::sync_with_stdio(0);
   cin.tie(0);
	cin >> n >> k;
	for ( int i = 1 ; i <= n ; i++ ) {
		cin >> a[i];
	}
	for ( int i = 1 ; i <= n ; i++ ){
		for ( int j = 0 ; j <= k ; j++ ){
			dp[i][j] = max(dp[i][j] , dp[i - 1][j] + a[i]);
			if ( j + 1 <= k ) dp[i][j + 1] = max(dp[i][j + 1] , dp[i - 1][j]);
		}
	}
	int ans = 0;
	for ( int i = 0 ; i <= k ; i++ ) ans = max(ans , dp[n][i]);
	cout << ans;
}
# Verdict Execution time Memory Grader output
1 Runtime error 11 ms 2136 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 2136 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 11 ms 2084 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 11 ms 2136 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -