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>
using namespace std;
long long max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W) {
long long ans = 0;
vector<int> is[2];
for(int i = 0; i < M; ++i) is[X[i]].push_back(i);
for(int u : {0, 1}) sort(begin(is[u]), end(is[u]), [&](const int& i, const int& j) { return Y[i] < Y[j]; });
for(int u : is[1]) ans += W[u];
long long Sans = ans;
int it = 0;
for(int u : is[0]) {
Sans += W[u];
while(it < (int)is[1].size() && Y[it] <= Y[u]) Sans -= W[it++];
ans = max(ans, Sans);
}
return ans;
}
# | 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... |