# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
626003 | aryan12 | Catfish Farm (IOI22_fish) | C++17 | 131 ms | 13556 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>
using namespace std;
// subtask 2
bool cmp(array<int, 3> a, array<int, 3> b)
{
if(a[1] != b[1]) return a[1] < b[1];
return a[0] > b[0];
}
long long max_weights(int N, int M, std::vector<int> X,
std::vector<int> Y, std::vector<int> W) {
long long ans1 = 0, ans2 = 0;
for(int i = 0; i < W.size(); i++)
{
if(X[i] == 0) ans1 += W[i];
else ans2 += W[i];
}
if(N == 2)
{
return max(ans1, ans2);
}
vector<array<int, 3> > vect;
for(int i = 0; i < W.size(); i++)
{
vect.push_back({X[i], Y[i], W[i]});
}
sort(vect.begin(), vect.end(), cmp);
long long cur_ans = max(ans1, ans2);
ans1 = 0;
for(int i = 0; i < vect.size(); i++)
{
if(vect[i][0] == 0)
{
ans1 += vect[i][2];
}
else
{
ans2 -= vect[i][2];
}
cur_ans = max(cur_ans, ans1 + ans2);
}
return cur_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... |