#include "fish.h"
#include <bits/stdc++.h>
using namespace std;
#define int long long
long long max_weights(int32_t n, int32_t m, std::vector<int32_t> x, std::vector<int32_t> y, std::vector<int32_t> w) {
vector<int> pref(n + 1, 0), suff(n + 1, 0);
for (int i = 0; i < m; i++) {
if (x[i] == 0) pref[y[i]] += w[i];
else if (x[i] == 1) suff[y[i]] += w[i];
}
for (int i = 1; i < n; i++) pref[i] += pref[i-1];
for (int i = n - 2; i >= 0; i--) suff[i] += suff[i+1];
int ans = suff[0];
for (int i = 0; i < n; i++) ans = max(ans, pref[i] + suff[i + 1]);
return ans;
}
#ifndef EVAL
int32_t main() {
int32_t N, M;
assert(2 == scanf("%d %d", &N, &M));
std::vector<int32_t> X(M), Y(M), W(M);
for (int32_t i = 0; i < M; ++i) {
assert(3 == scanf("%d %d %d", &X[i], &Y[i], &W[i]));
}
long long result = max_weights(N, M, X, Y, W);
printf("%lld\n", result);
return 0;
}
#endif
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
24 ms |
3552 KB |
Output is correct |
2 |
Correct |
28 ms |
4232 KB |
Output is correct |
3 |
Correct |
2 ms |
1748 KB |
Output is correct |
4 |
Correct |
2 ms |
1748 KB |
Output is correct |
5 |
Incorrect |
85 ms |
8932 KB |
1st lines differ - on the 1st token, expected: '149814460735479', found: '0' |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
49 ms |
5400 KB |
Output is correct |
3 |
Correct |
65 ms |
9920 KB |
Output is correct |
4 |
Correct |
25 ms |
4952 KB |
Output is correct |
5 |
Correct |
30 ms |
5936 KB |
Output is correct |
6 |
Incorrect |
1 ms |
340 KB |
1st lines differ - on the 1st token, expected: '4044', found: '6066' |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1876 KB |
Output is correct |
2 |
Incorrect |
2 ms |
1876 KB |
1st lines differ - on the 1st token, expected: '882019', found: '0' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1876 KB |
Output is correct |
2 |
Incorrect |
2 ms |
1876 KB |
1st lines differ - on the 1st token, expected: '882019', found: '0' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
24 ms |
3552 KB |
Output is correct |
2 |
Correct |
28 ms |
4232 KB |
Output is correct |
3 |
Correct |
2 ms |
1748 KB |
Output is correct |
4 |
Correct |
2 ms |
1748 KB |
Output is correct |
5 |
Incorrect |
85 ms |
8932 KB |
1st lines differ - on the 1st token, expected: '149814460735479', found: '0' |
6 |
Halted |
0 ms |
0 KB |
- |