#include "fish.h"
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y,
std::vector<int> W) {
i64 s[N] {};
map<pair<int, int>, int> f;
for (int i = 0; i < M; i++) {
s[X[i]] += W[i];
f[{X[i], Y[i]}] = W[i];
}
if (N == 2) {
return max(s[0], s[1]);
}
vector pre(2, vector<i64>(N + 1));
for (int i = 0; i < 2; i++) {
for (int j = 0; j < N; j++) {
pre[i][j + 1] = pre[i][j] + f[{i, j}];
}
}
i64 ans = 0;
for (int i = 0; i <= N; i++) {
ans = max(ans, pre[1][N] - pre[1][i] + pre[0][i]);
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
64 ms |
15500 KB |
Output is correct |
2 |
Correct |
81 ms |
17408 KB |
Output is correct |
3 |
Correct |
38 ms |
15064 KB |
Output is correct |
4 |
Correct |
38 ms |
15096 KB |
Output is correct |
5 |
Incorrect |
259 ms |
40892 KB |
1st lines differ - on the 1st token, expected: '149814460735479', found: '0' |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
120 ms |
17448 KB |
Output is correct |
3 |
Correct |
136 ms |
20548 KB |
Output is correct |
4 |
Correct |
63 ms |
15500 KB |
Output is correct |
5 |
Correct |
80 ms |
17468 KB |
Output is correct |
6 |
Correct |
1 ms |
228 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
296 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
38 ms |
15156 KB |
Output is correct |
11 |
Correct |
38 ms |
15164 KB |
Output is correct |
12 |
Correct |
73 ms |
16896 KB |
Output is correct |
13 |
Correct |
84 ms |
19244 KB |
Output is correct |
14 |
Correct |
67 ms |
16908 KB |
Output is correct |
15 |
Correct |
80 ms |
18792 KB |
Output is correct |
16 |
Correct |
69 ms |
16912 KB |
Output is correct |
17 |
Correct |
78 ms |
18732 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
37 ms |
15032 KB |
Output is correct |
2 |
Incorrect |
38 ms |
15104 KB |
1st lines differ - on the 1st token, expected: '882019', found: '0' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 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 |
1 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 |
1 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 |
37 ms |
15032 KB |
Output is correct |
2 |
Incorrect |
38 ms |
15104 KB |
1st lines differ - on the 1st token, expected: '882019', found: '0' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
64 ms |
15500 KB |
Output is correct |
2 |
Correct |
81 ms |
17408 KB |
Output is correct |
3 |
Correct |
38 ms |
15064 KB |
Output is correct |
4 |
Correct |
38 ms |
15096 KB |
Output is correct |
5 |
Incorrect |
259 ms |
40892 KB |
1st lines differ - on the 1st token, expected: '149814460735479', found: '0' |
6 |
Halted |
0 ms |
0 KB |
- |