#include "fish.h"
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const int MAX_N = 1e5 + 5, MAX_M = 3e5 + 5;
int n, m;
int x[MAX_M], y[MAX_M];
lint w[MAX_M];
lint w_at[2][MAX_N];
lint w_sum[2][MAX_N];
void precomp() {
for (int i = 0; i < m; i++)
w_at[x[i]][y[i]] = w[i];
for (int i = 0; i <= 1; i++)
for (int j = 0; j < n; j++)
w_sum[i][j] = w_at[i][j] + ((j == 0) ? 0 : w_sum[i][j - 1]);
}
void init() {
for (int i = 0; i <= 1; i++)
for (int j = 0; j < n; j++)
w_at[i][j] = 0;
}
lint max_weights(int tmp_n, int tmp_m, vector<int> tmp_x, vector<int> tmp_y, vector<int> tmp_w) {
n = tmp_n; assert(n != 2);
m = tmp_m;
init();
for (int i = 0; i < m; i++) {
x[i] = tmp_x[i];
y[i] = tmp_y[i];
w[i] = tmp_w[i];
}
precomp();
lint ans = w_sum[1][n - 1];
for (int y = 0; y < n; y++) {
lint new_ans = w_sum[1][n - 1] - w_sum[1][y] + w_sum[0][y];
ans = max(ans, new_ans);
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
8796 KB |
Output is correct |
2 |
Correct |
23 ms |
9300 KB |
Output is correct |
3 |
Correct |
2 ms |
6748 KB |
Output is correct |
4 |
Correct |
2 ms |
6748 KB |
Output is correct |
5 |
Runtime error |
79 ms |
30292 KB |
Execution killed with signal 11 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
6492 KB |
Output is correct |
2 |
Correct |
45 ms |
11048 KB |
Output is correct |
3 |
Correct |
53 ms |
12116 KB |
Output is correct |
4 |
Correct |
18 ms |
8820 KB |
Output is correct |
5 |
Correct |
23 ms |
9304 KB |
Output is correct |
6 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 6 |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
6748 KB |
Output is correct |
2 |
Runtime error |
6 ms |
12892 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
6492 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 |
6492 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 |
6492 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 |
2 ms |
6748 KB |
Output is correct |
2 |
Runtime error |
6 ms |
12892 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
8796 KB |
Output is correct |
2 |
Correct |
23 ms |
9300 KB |
Output is correct |
3 |
Correct |
2 ms |
6748 KB |
Output is correct |
4 |
Correct |
2 ms |
6748 KB |
Output is correct |
5 |
Runtime error |
79 ms |
30292 KB |
Execution killed with signal 11 |
6 |
Halted |
0 ms |
0 KB |
- |