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 <iostream>
#include <vector>
#define ll long long
using namespace std;
ll max_weights(int n, int m, vector<int> x, vector<int> y, vector<int> w) {
ll res;
if(n == 2) {
ll r0 = 0, r1 = 0;
for(ll i = 0; i < m; i++) {
if(x[i]) r1+=w[i];
else r0+=w[i];
}
res = max(r0, r1);
} else {
vector<ll> pref0(n), pref1(n);
for(int i = 0; i < m; i++) {
if(x[i]) pref1[y[i]] = w[i];
else pref0[y[i]] = w[i];
}
for(int i = 1; i < n; i++) {
pref0[i]+=pref0[i-1];
pref1[i]+=pref1[i-1];
}
res = pref1[n-1];
for(int i = 0; i < n; i++) res = max(res, pref0[i]+pref1[n-1]-pref1[i]);
}
return res;
}
# | 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... |