#include "fish.h"
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <iostream>
#include <cstring>
bool locatedAt0(std::vector<int> Y) {
for (auto y : Y) {
if (y != 0) {
return false;
}
}
return true;
}
long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y, std::vector<int> W) {
if (locatedAt0(Y)) {
long long a[N + 1];
long long dp[N + 1][2];
memset(a, 0, sizeof a);
memset(dp, 0, sizeof dp);
for (int i = 0; i < M; ++i) {
a[X[i]] = W[i];
}
dp[0][0] = 0;
dp[0][1] = a[1];
dp[1][0] = a[1];
dp[1][1] = a[0] + a[2];
for (int i = 2; i < N; ++i) {
dp[i][0] = std::max(dp[i - 1][1], dp[i - 1][0]),
dp[i][1] = std::max(dp[i - 2][0] + a[i - 1] + a[i + 1], dp[i - 2][1] + a[i + 1]);
dp[i][1] = std::max(dp[i - 1][1] - a[i] + a[i + 1], dp[i][1]);
}
return std::max(dp[N - 1][0], dp[N - 1][1]);
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
22 ms |
2516 KB |
1st lines differ - on the 1st token, expected: '40313272768926', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
1st lines differ - on the 1st token, expected: '2', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
2 ms |
2644 KB |
Output is correct |
3 |
Correct |
16 ms |
3760 KB |
Output is correct |
4 |
Correct |
11 ms |
3516 KB |
Output is correct |
5 |
Correct |
36 ms |
4932 KB |
Output is correct |
6 |
Correct |
24 ms |
5000 KB |
Output is correct |
7 |
Correct |
27 ms |
5128 KB |
Output is correct |
8 |
Correct |
27 ms |
5052 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
1st lines differ - on the 1st token, expected: '3', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
1st lines differ - on the 1st token, expected: '3', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
1st lines differ - on the 1st token, expected: '3', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
2 ms |
2644 KB |
Output is correct |
3 |
Correct |
16 ms |
3760 KB |
Output is correct |
4 |
Correct |
11 ms |
3516 KB |
Output is correct |
5 |
Correct |
36 ms |
4932 KB |
Output is correct |
6 |
Correct |
24 ms |
5000 KB |
Output is correct |
7 |
Correct |
27 ms |
5128 KB |
Output is correct |
8 |
Correct |
27 ms |
5052 KB |
Output is correct |
9 |
Incorrect |
29 ms |
3072 KB |
1st lines differ - on the 1st token, expected: '99999', found: '0' |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
22 ms |
2516 KB |
1st lines differ - on the 1st token, expected: '40313272768926', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |