This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 += (ll)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]] = (ll)w[i];
else a[y[i]] = (ll)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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |