# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
533895 |
2022-03-07T14:59:58 Z |
idas |
Feast (NOI19_feast) |
C++11 |
|
35 ms |
59052 KB |
#include <bits/stdc++.h>
#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr)
#define FOR(i, begin, end) for(int i = (begin); i < (end); i++)
#define TSTS int ttt; cin >> ttt; while(ttt--) solve()
#define all(x) (x).begin(), (x).end()
#define le(vec) vec[vec.size()-1]
#define sz(x) ((int)((x).size()))
#define pb push_back
#define s second
#define f first
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<long double, long double> pdd;
const int INF=1e9, MOD=1e9+7, mod=998244353;
const ll LINF=1e13;
void setIO()
{
FAST_IO;
}
void setIO(string s)
{
FAST_IO;
freopen((s+".in").c_str(), "r", stdin);
freopen((s+".out").c_str(), "w", stdout);
}
const int N=2e3+10;
int n, k, a[N];
ll dp[N][N][2];
int main()
{
setIO();
cin >> n >> k;
FOR(i, 0, n) cin >> a[i];
FOR(i, 1, n+1)
{
FOR(j, 1, k+1)
{
dp[i][j][1]=max({
dp[i-1][j][1]+a[i-1],
dp[i-1][j-1][0]+a[i-1],
dp[i-1][j-1][1]+a[i-1]
});
dp[i][j][0]=max({
dp[i-1][j][1],
dp[i-1][j][0],
dp[i-1][j-1][1],
dp[i-1][j-1][0]
});
}
}
cout << max(dp[n][k][0], dp[n][k][1]);
}
Compilation message
feast.cpp: In function 'void setIO(std::string)':
feast.cpp:32:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
32 | freopen((s+".in").c_str(), "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
feast.cpp:33:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
33 | freopen((s+".out").c_str(), "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
460 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
5716 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
592 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
588 KB |
Output is correct |
2 |
Correct |
1 ms |
708 KB |
Output is correct |
3 |
Correct |
1 ms |
588 KB |
Output is correct |
4 |
Correct |
1 ms |
540 KB |
Output is correct |
5 |
Correct |
1 ms |
576 KB |
Output is correct |
6 |
Correct |
1 ms |
588 KB |
Output is correct |
7 |
Correct |
1 ms |
588 KB |
Output is correct |
8 |
Correct |
1 ms |
588 KB |
Output is correct |
9 |
Correct |
1 ms |
576 KB |
Output is correct |
10 |
Correct |
1 ms |
588 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
588 KB |
Output is correct |
2 |
Correct |
1 ms |
708 KB |
Output is correct |
3 |
Correct |
1 ms |
588 KB |
Output is correct |
4 |
Correct |
1 ms |
540 KB |
Output is correct |
5 |
Correct |
1 ms |
576 KB |
Output is correct |
6 |
Correct |
1 ms |
588 KB |
Output is correct |
7 |
Correct |
1 ms |
588 KB |
Output is correct |
8 |
Correct |
1 ms |
588 KB |
Output is correct |
9 |
Correct |
1 ms |
576 KB |
Output is correct |
10 |
Correct |
1 ms |
588 KB |
Output is correct |
11 |
Correct |
1 ms |
1604 KB |
Output is correct |
12 |
Correct |
1 ms |
1612 KB |
Output is correct |
13 |
Correct |
1 ms |
1356 KB |
Output is correct |
14 |
Correct |
1 ms |
1612 KB |
Output is correct |
15 |
Correct |
1 ms |
1484 KB |
Output is correct |
16 |
Correct |
1 ms |
1356 KB |
Output is correct |
17 |
Correct |
1 ms |
1612 KB |
Output is correct |
18 |
Correct |
1 ms |
1356 KB |
Output is correct |
19 |
Correct |
2 ms |
1356 KB |
Output is correct |
20 |
Correct |
1 ms |
1468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
588 KB |
Output is correct |
2 |
Correct |
1 ms |
708 KB |
Output is correct |
3 |
Correct |
1 ms |
588 KB |
Output is correct |
4 |
Correct |
1 ms |
540 KB |
Output is correct |
5 |
Correct |
1 ms |
576 KB |
Output is correct |
6 |
Correct |
1 ms |
588 KB |
Output is correct |
7 |
Correct |
1 ms |
588 KB |
Output is correct |
8 |
Correct |
1 ms |
588 KB |
Output is correct |
9 |
Correct |
1 ms |
576 KB |
Output is correct |
10 |
Correct |
1 ms |
588 KB |
Output is correct |
11 |
Correct |
1 ms |
1604 KB |
Output is correct |
12 |
Correct |
1 ms |
1612 KB |
Output is correct |
13 |
Correct |
1 ms |
1356 KB |
Output is correct |
14 |
Correct |
1 ms |
1612 KB |
Output is correct |
15 |
Correct |
1 ms |
1484 KB |
Output is correct |
16 |
Correct |
1 ms |
1356 KB |
Output is correct |
17 |
Correct |
1 ms |
1612 KB |
Output is correct |
18 |
Correct |
1 ms |
1356 KB |
Output is correct |
19 |
Correct |
2 ms |
1356 KB |
Output is correct |
20 |
Correct |
1 ms |
1468 KB |
Output is correct |
21 |
Correct |
7 ms |
14284 KB |
Output is correct |
22 |
Correct |
35 ms |
59052 KB |
Output is correct |
23 |
Correct |
10 ms |
19916 KB |
Output is correct |
24 |
Correct |
8 ms |
14796 KB |
Output is correct |
25 |
Correct |
11 ms |
17484 KB |
Output is correct |
26 |
Correct |
8 ms |
13772 KB |
Output is correct |
27 |
Correct |
10 ms |
16972 KB |
Output is correct |
28 |
Correct |
4 ms |
9292 KB |
Output is correct |
29 |
Correct |
4 ms |
9164 KB |
Output is correct |
30 |
Correct |
4 ms |
8268 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
460 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |