#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 |
65 ms |
15576 KB |
Output is correct |
2 |
Correct |
85 ms |
17508 KB |
Output is correct |
3 |
Correct |
39 ms |
15172 KB |
Output is correct |
4 |
Correct |
38 ms |
15036 KB |
Output is correct |
5 |
Incorrect |
261 ms |
40940 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 |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
103 ms |
17420 KB |
Output is correct |
3 |
Correct |
132 ms |
24140 KB |
Output is correct |
4 |
Correct |
71 ms |
16908 KB |
Output is correct |
5 |
Correct |
82 ms |
19140 KB |
Output is correct |
6 |
Incorrect |
1 ms |
212 KB |
1st lines differ - on the 1st token, expected: '4044', found: '140728787205820' |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
38 ms |
15172 KB |
Output is correct |
2 |
Incorrect |
41 ms |
15036 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 |
38 ms |
15172 KB |
Output is correct |
2 |
Incorrect |
41 ms |
15036 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 |
65 ms |
15576 KB |
Output is correct |
2 |
Correct |
85 ms |
17508 KB |
Output is correct |
3 |
Correct |
39 ms |
15172 KB |
Output is correct |
4 |
Correct |
38 ms |
15036 KB |
Output is correct |
5 |
Incorrect |
261 ms |
40940 KB |
1st lines differ - on the 1st token, expected: '149814460735479', found: '0' |
6 |
Halted |
0 ms |
0 KB |
- |