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 <vector>
#include <iostream>
// #include <bits/stdc++.h>
#include <algorithm>
void start() {
//1 call
}
using namespace std;
long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y,
std::vector<int> W) {
long long ans = 0, now = 0, a = 0, b = 0;
vector<pair<int, pair<int, int> > > nums;
for (int i = 0; i < M; i++) {
nums.push_back({Y[i], {X[i], W[i]}});
if (X[i] == 1)
now += W[i], b += W[i];
else
a += W[i];
}
if (N == 2)
return max(a, b);
sort(nums.begin(), nums.end());
for (int i = 0; i < M; i++) {
cout << nums[i].first << ' ' << nums[i].second.first << '\n';
if (i == 0 || nums[i].first != nums[i-1].first)
ans = max(ans, now);
if (nums[i].second.first == 0)
now += nums[i].second.second;
else
now -= nums[i].second.second;
}
ans = max(ans, now);
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... |