# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
848127 |
2023-09-11T12:11:59 Z |
nguyennh |
Feast (NOI19_feast) |
C++14 |
|
13 ms |
3420 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[2005][2005];
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 |
10 ms |
3124 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
7 ms |
2648 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
13 ms |
3420 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
604 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
604 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
604 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
10 ms |
3124 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |