#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;
if (n == 2) {
ll sumA = 0, sumB = 0;
for (int i = 0; i < m; i++) {
if (x[i] > 0) sumB += w[i];
else sumA += w[i];
}
return max(sumA, sumB);
}
ll res = 0;
for (int i = 0; i < m; i++) {
if (x[i] > 0) res += w[i];
}
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 |
17 ms |
5976 KB |
Output is correct |
2 |
Correct |
19 ms |
7252 KB |
Output is correct |
3 |
Correct |
1 ms |
1880 KB |
Output is correct |
4 |
Correct |
1 ms |
1880 KB |
Output is correct |
5 |
Correct |
57 ms |
18924 KB |
Output is correct |
6 |
Incorrect |
59 ms |
19028 KB |
1st lines differ - on the 1st token, expected: '300000000000000', found: '299997000000000' |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
31 ms |
10264 KB |
Output is correct |
3 |
Correct |
47 ms |
12368 KB |
Output is correct |
4 |
Correct |
15 ms |
5976 KB |
Output is correct |
5 |
Correct |
18 ms |
7256 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
1884 KB |
Output is correct |
11 |
Correct |
1 ms |
1880 KB |
Output is correct |
12 |
Correct |
15 ms |
5880 KB |
Output is correct |
13 |
Correct |
19 ms |
7232 KB |
Output is correct |
14 |
Correct |
17 ms |
6076 KB |
Output is correct |
15 |
Correct |
20 ms |
6748 KB |
Output is correct |
16 |
Correct |
18 ms |
5980 KB |
Output is correct |
17 |
Correct |
20 ms |
6744 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1884 KB |
Output is correct |
2 |
Correct |
1 ms |
1884 KB |
Output is correct |
3 |
Incorrect |
15 ms |
4700 KB |
1st lines differ - on the 1st token, expected: '21261825233649', found: '26722445760742' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
436 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 1st token, expected: '216624184325', found: '310563953458' |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
436 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 1st token, expected: '216624184325', found: '310563953458' |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
436 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 1st token, expected: '216624184325', found: '310563953458' |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1884 KB |
Output is correct |
2 |
Correct |
1 ms |
1884 KB |
Output is correct |
3 |
Incorrect |
15 ms |
4700 KB |
1st lines differ - on the 1st token, expected: '21261825233649', found: '26722445760742' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
5976 KB |
Output is correct |
2 |
Correct |
19 ms |
7252 KB |
Output is correct |
3 |
Correct |
1 ms |
1880 KB |
Output is correct |
4 |
Correct |
1 ms |
1880 KB |
Output is correct |
5 |
Correct |
57 ms |
18924 KB |
Output is correct |
6 |
Incorrect |
59 ms |
19028 KB |
1st lines differ - on the 1st token, expected: '300000000000000', found: '299997000000000' |
7 |
Halted |
0 ms |
0 KB |
- |