#include <bits/stdc++.h>
using namespace std;
#define ll long long int
ll max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W) {
ll pref0[N + 1], pref1[N + 1];
for (int i = 0; i < M; i++) {
if (X[i] == 0) pref0[Y[i] + 1] += W[i];
else pref1[Y[i] + 1] += W[i];
}
for (int i = 1; i <= N; i++) {
pref0[i] += pref0[i - 1]; pref1[i] += pref1[i - 1];
}
ll ans1 = 0, ans2 = 0, ans3 = 0;
for (int i = 0; i <= N; i++) {
ans1 = max(ans1, pref1[i]);
ans2 = max(ans2, pref0[i]);
ans3 = max(ans3, pref1[N] - pref1[i] + pref0[i]);
}
if (N == 2) return max(ans1, ans2);
else return max(ans1, max(ans2, ans3));
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
25 ms |
3564 KB |
1st lines differ - on the 1st token, expected: '40313272768926', found: '8031351089699165071' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
1st lines differ - on the 1st token, expected: '2', found: '562945024365281' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
1748 KB |
1st lines differ - on the 1st token, expected: '10082010', found: '8031310848389364439' |
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: '422197669443327' |
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: '422197669443327' |
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: '422197669443327' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
1748 KB |
1st lines differ - on the 1st token, expected: '10082010', found: '8031310848389364439' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
25 ms |
3564 KB |
1st lines differ - on the 1st token, expected: '40313272768926', found: '8031351089699165071' |
2 |
Halted |
0 ms |
0 KB |
- |