# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1044694 | Dan4Life | Catfish Farm (IOI22_fish) | C++17 | 197 ms | 481728 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;
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) begin(a),end(a)
using ll = long long;
using vi = vector<int>;
const int mxN = (int)1e5+10;
const int mxN2 = (int)3e2+10;
const ll LINF = (ll)2e18;
int n, m;
struct Fish{ int x, y; ll w; };
vector<Fish> fishes;
ll dp[mxN2][mxN2][mxN2];
ll pref[4][mxN];
ll max_weights(int N, int M, vi _X, vi _Y, vi _W) {
n = N, m = M; ll ans = 0;
for(int i = 0; i < m; i++)
fishes.pb({_X[i]+1,_Y[i]+1,_W[i]});
sort(all(fishes),[&](Fish a, Fish b){
if(a.x!=b.x) return a.x<b.x;
return a.y<b.y;
});
if(fishes.back().x <=2){
for(int i = 0; i < m; i++){
auto [x,y,w] = fishes[i];
pref[x][y]+=w;
}
for(int i = 0; i <= n; i++)
for(int j = 1; j <= n; j++)
pref[i][j]+=pref[i][j-1];
for(int i = 0; i <= n; i++){
ans = max({ans, pref[1][i], pref[2][i]});
}
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... |