#include <bits/stdc++.h>
#include "fish.h"
using namespace std;
typedef long long ll;
int n, m;
vector<int> x, y, w;
ll max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W) {
n = N; m = M; x = X; y = Y; w = W;
ll res = 0;
for (int i = 0; i < m; i++) {
if (x[i] > 0) res += w[i];
if (x[i] > 1) return 0;
}
ll mx = res;
vector<ll> a(n), b(n);
for (int i = 0; i < m; i++) {
if (x[i] > 0) b[y[i]] = w[i];
else a[y[i]] = w[i];
}
for (int i = 0; i < n; i++) {
res -= b[i];
res += a[i];
mx = max(mx, res);
}
return mx;
}
#ifdef TEST
#include "grader.cpp"
#endif
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
5980 KB |
Output is correct |
2 |
Correct |
19 ms |
7236 KB |
Output is correct |
3 |
Correct |
1 ms |
1884 KB |
Output is correct |
4 |
Correct |
1 ms |
1884 KB |
Output is correct |
5 |
Incorrect |
72 ms |
17132 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 |
348 KB |
Output is correct |
2 |
Correct |
32 ms |
10324 KB |
Output is correct |
3 |
Correct |
39 ms |
12456 KB |
Output is correct |
4 |
Correct |
15 ms |
6080 KB |
Output is correct |
5 |
Correct |
18 ms |
7252 KB |
Output is correct |
6 |
Incorrect |
1 ms |
348 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 |
1 ms |
1884 KB |
Output is correct |
2 |
Incorrect |
0 ms |
428 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 |
0 ms |
348 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 |
0 ms |
348 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 |
0 ms |
348 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 |
1884 KB |
Output is correct |
2 |
Incorrect |
0 ms |
428 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 |
16 ms |
5980 KB |
Output is correct |
2 |
Correct |
19 ms |
7236 KB |
Output is correct |
3 |
Correct |
1 ms |
1884 KB |
Output is correct |
4 |
Correct |
1 ms |
1884 KB |
Output is correct |
5 |
Incorrect |
72 ms |
17132 KB |
1st lines differ - on the 1st token, expected: '149814460735479', found: '0' |
6 |
Halted |
0 ms |
0 KB |
- |