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 "fish.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, pair<int, int> > piii;
#define X first
#define Y second
ll max_weights(int n, int m, vector<int> x, vector<int> y, vector<int> w) {
vector<piii> A;
ll first = 0LL, second = 0LL;
for(int i = 0; i < m; i++) {
if(x[i] == 0)
first += 1LL*w[i];
else
second += 1LL*w[i];
A.push_back({y[i], {x[i], w[i]}});
}
if(n == 2)
return max(first, second);
ll ans = 0LL;
sort(A.begin(), A.end());
first = 0LL;
for(int i = 0; i < m; i++) {
if(A[i].Y.X == 0)
first += 1LL*A[i].Y.Y;
else
second -= 1LL*A[i].Y.Y;
if(i+1 != m && A[i+1].Y.X == 1 && A[i].Y.X == 0 && A[i].X == A[i+1].X) continue;
ans = max(ans, first+second);
}
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... |