# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
827880 | Seb | Catfish Farm (IOI22_fish) | C++17 | 108 ms | 15580 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;
typedef long long ll;
#define f first
#define s second
long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y,std::vector<int> W) {
if (N==2) {
ll a=0,b=0;
for (int i=0;i<M;i++) {
if (X[i]==0) a += W[i];
else b += W[i];
}
return max(a,b);
}
else {
ll ans = 0,a=0,b=0,p0=0,p1=0;
vector <pair<ll,ll>> cero,uno;
for (int i=0;i<M;i++) {
if (X[i]==1) {
b += W[i];
uno.push_back({Y[i],W[i]});
}
else cero.push_back({Y[i],W[i]});
}
sort(cero.begin(),cero.end());
sort(uno.begin(),uno.end());
for (p0=0;p0<cero.size();p0++) {
ans = max(ans,a+b);
a += cero[p0].s;
while (p1<uno.size() && uno[p1].f <= cero[p0].f) {
b -= uno[p1].s;
p1++;
}
}
ans = max(ans,a+b);
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... |