#include "fish.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;
#define f0(i, n) for(int i = 0; i < (n); i++)
#define f1(i, n) for(int i = 1; i <= (n); i++)
#define pb push_back
#define ff first
#define ss second
typedef vector<int> vi;
typedef long long ll;
long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y,
std::vector<int> W) {
bool allxeven = true;
bool allxleq1 = true;
bool ally0 = true;
f0(i, M) {
if(X[i] % 2 == 1) allxeven = false;
if(X[i] > 1) allxleq1 = false;
if(Y[i] != 0) ally0 = false;
}
if (allxeven) {
ll ret = 0;
f0(i, M) ret += W[i];
return ret;
}
if(allxleq1) {
ll ret = 0;
ll ans = 0;
int arr[N][2];
f0(i, N) arr[i][0] = 0, arr[i][1] = 0;
f0(i, M) {
arr[X[i]][Y[i]] = W[i];
}
f0(i, N) {
ans += arr[i][1];
}
ret = ans;
f0(i, N) {
ans -= arr[i][1];
ans += arr[i][0];
ret = max(ret, ans);
}
return ret;
}
if(ally0) {
int arr[N];
f0(i, N) arr[i] = 0;
f0(i, M) arr[X[i]] = W[i];
ll dp[N][4];
dp[0][0] = -1e18;
dp[0][1] = -1e18;
dp[0][2] = 0;
dp[0][3] = arr[0];
dp[1][0] = 0;
dp[1][1] = arr[1];
dp[1][2] = arr[0];
dp[1][3] = -1e18;
f1(i, N-2) {
dp[i+1][0] = max(dp[i][0], dp[i][2]);
dp[i+1][1] = max(dp[i][0], dp[i][2]) + arr[i+1];
dp[i+1][2] = max(dp[i][1], dp[i][3]);
dp[i+1][3] = dp[i][1] + arr[i+1];
}
return max({
dp[N-1][0],
dp[N-1][1],
dp[N-1][2]
});
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
38 ms |
3528 KB |
Output is correct |
2 |
Correct |
30 ms |
4276 KB |
Output is correct |
3 |
Correct |
2 ms |
300 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
96 ms |
13652 KB |
Output is correct |
6 |
Correct |
110 ms |
13940 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
81 ms |
7560 KB |
1st lines differ - on the 1st token, expected: '40604614618209', found: '22269719695488' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
3 ms |
3756 KB |
Output is correct |
3 |
Correct |
19 ms |
5580 KB |
Output is correct |
4 |
Correct |
16 ms |
5188 KB |
Output is correct |
5 |
Correct |
41 ms |
7704 KB |
Output is correct |
6 |
Correct |
33 ms |
7100 KB |
Output is correct |
7 |
Correct |
30 ms |
7624 KB |
Output is correct |
8 |
Correct |
33 ms |
7736 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
300 KB |
1st lines differ - on the 1st token, expected: '3', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
300 KB |
1st lines differ - on the 1st token, expected: '3', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
300 KB |
1st lines differ - on the 1st token, expected: '3', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
3 ms |
3756 KB |
Output is correct |
3 |
Correct |
19 ms |
5580 KB |
Output is correct |
4 |
Correct |
16 ms |
5188 KB |
Output is correct |
5 |
Correct |
41 ms |
7704 KB |
Output is correct |
6 |
Correct |
33 ms |
7100 KB |
Output is correct |
7 |
Correct |
30 ms |
7624 KB |
Output is correct |
8 |
Correct |
33 ms |
7736 KB |
Output is correct |
9 |
Incorrect |
32 ms |
3880 KB |
1st lines differ - on the 1st token, expected: '99999', found: '0' |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
38 ms |
3528 KB |
Output is correct |
2 |
Correct |
30 ms |
4276 KB |
Output is correct |
3 |
Correct |
2 ms |
300 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
96 ms |
13652 KB |
Output is correct |
6 |
Correct |
110 ms |
13940 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Incorrect |
81 ms |
7560 KB |
1st lines differ - on the 1st token, expected: '40604614618209', found: '22269719695488' |
9 |
Halted |
0 ms |
0 KB |
- |