# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
747819 | b00norp | Catfish Farm (IOI22_fish) | C++17 | 152 ms | 29756 KiB |
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>
#include <vector>
using namespace std;
bool cmp(array<long long, 3> a, array<long long, 3> b)
{
if(a[1] == b[1])
{
return a[0] > b[0];
}
return a[1] < b[1];
}
long long max_weights(int n, int m, vector<int> x,
vector<int> y, vector<int> w)
{
long long N = n, M = m;
vector<long long> X, Y, W;
for(long long i = 0; i < M; i++)
{
X.push_back(x[i]);
Y.push_back(y[i]);
W.push_back(w[i]);
}
if(N == 2)
{
vector<long long> ans(2, 0);
for(long long i = 0; i < M; i++)
{
ans[X[i]] += W[i];
}
return max(ans[0], ans[1]);
}
vector<array<long long, 3> > fishes;
for(long long i = 0; i < M; i++)
{
fishes.push_back({X[i], Y[i], W[i]});
}
sort(fishes.begin(), fishes.end(), cmp);
long long ans = 0, cur_ans = 0;
for(long long i = 0; i < fishes.size(); i++)
{
if(fishes[i][0] == 1)
{
cur_ans += fishes[i][2];
}
}
ans = cur_ans;
for(long long i = 0; i < fishes.size(); i++)
{
if(fishes[i][0] == 1)
{
cur_ans -= fishes[i][2];
}
else
{
cur_ans += fishes[i][2];
}
ans = max(ans, cur_ans);
}
return ans;
}
Compilation message (stderr)
# | 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... |