#pragma GCC optimize("O3")
#include "fish.h"
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;
const ll INF = 3e14 + 4;
ll max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W) {
int flag = 0;
for(int i = 0; i < M; i++){
if(Y[i] != 0){
flag = 1;
}
}
if(!flag){
ll dp[N][2], a[N];
memset(dp, 0, sizeof(dp)); memset(a, 0, sizeof(a));
for(int i = 0; i < M; i++) a[X[i]] += W[i];
dp[1][0] = a[1];
dp[1][1] = a[0];
for(int i = 2; i < N; i++){
dp[i][0] = max(dp[i - 1][1] + a[i], dp[i - 1][0]);
dp[i][1] = max(max(dp[i - 2][0] + a[i - 1], dp[i - 1][1]), dp[i - 2][1] + a[i - 1]);
}
return max(dp[N - 1][0], dp[N - 1][1]);
}
ll ans[N + 1][2];
memset(ans, 0, sizeof(ans));
for(int i = 0; i < M; i++){
ans[Y[i] + 1][X[i]] = W[i];
}
for(int i = 1; i <= N; i++){
ans[i][0] += ans[i - 1][0];
ans[i][1] += ans[i - 1][1];
}
ll res = 0;
for (int i = 0; i <= N; i++)
{
res = max(res, ans[i][0] + (ans[N][1] - ans[i][1]));
}
return res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
3532 KB |
Output is correct |
2 |
Correct |
27 ms |
4164 KB |
Output is correct |
3 |
Correct |
2 ms |
2644 KB |
Output is correct |
4 |
Correct |
1 ms |
1748 KB |
Output is correct |
5 |
Runtime error |
93 ms |
17776 KB |
Execution killed with signal 11 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
45 ms |
5396 KB |
Output is correct |
3 |
Correct |
61 ms |
6484 KB |
Output is correct |
4 |
Correct |
24 ms |
3552 KB |
Output is correct |
5 |
Correct |
27 ms |
4152 KB |
Output is correct |
6 |
Incorrect |
1 ms |
212 KB |
1st lines differ - on the 1st token, expected: '4044', found: '6066' |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
2 ms |
2644 KB |
Output is correct |
3 |
Correct |
15 ms |
3668 KB |
Output is correct |
4 |
Correct |
11 ms |
3412 KB |
Output is correct |
5 |
Correct |
26 ms |
4948 KB |
Output is correct |
6 |
Correct |
22 ms |
4940 KB |
Output is correct |
7 |
Correct |
26 ms |
5068 KB |
Output is correct |
8 |
Correct |
28 ms |
4936 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
1st lines differ - on the 1st token, expected: '3', found: '2' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
1st lines differ - on the 1st token, expected: '3', found: '2' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
1st lines differ - on the 1st token, expected: '3', found: '2' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
2 ms |
2644 KB |
Output is correct |
3 |
Correct |
15 ms |
3668 KB |
Output is correct |
4 |
Correct |
11 ms |
3412 KB |
Output is correct |
5 |
Correct |
26 ms |
4948 KB |
Output is correct |
6 |
Correct |
22 ms |
4940 KB |
Output is correct |
7 |
Correct |
26 ms |
5068 KB |
Output is correct |
8 |
Correct |
28 ms |
4936 KB |
Output is correct |
9 |
Runtime error |
29 ms |
8268 KB |
Execution killed with signal 11 |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
3532 KB |
Output is correct |
2 |
Correct |
27 ms |
4164 KB |
Output is correct |
3 |
Correct |
2 ms |
2644 KB |
Output is correct |
4 |
Correct |
1 ms |
1748 KB |
Output is correct |
5 |
Runtime error |
93 ms |
17776 KB |
Execution killed with signal 11 |
6 |
Halted |
0 ms |
0 KB |
- |