# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
756067 | yeyso | Catfish Farm (IOI22_fish) | C++17 | 49 ms | 15912 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;
#include <vector>
/*
N - rows and columns
M - number of fish
X, Y - coordinates
W - weights
Y[i] = 0 means that we can only harvest up to 3 fish at a time
*/
long long max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W) {
/*long long subtask1 = 1;
long long subtask2 = 1;
long long subtask3 = 1;
long long res = 0;
for(long long i = 0; i < W.size(); i ++){
if(X[i] % 2 == 0){
res += W[i];
} else {
subtask1 = 0;
}
if(Y[i] > 1){
subtask2 = 0;
}
}*/
vector<vector<long long>> fish(M, vector<long long>());
for(long long i = 0; i < M; i ++){
fish[i] = {X[i], Y[i], W[i]};
}
vector<long long> p(N, 0);
for(long long i = 0; i < M; i ++){
p[X[i]] = W[i];
}
vector<vector<long long>> dp(N+1, vector<long long>(3, 0));
dp[0][0] = 0;
dp[0][1] = 0;
dp[0][2] = p[0];
for(long long i = 1; i < p.size(); i ++){
dp[i][1] = dp[i-1][0]+p[i];
dp[i][2] = max(dp[i-1][0], dp[i-1][1])+p[i];
dp[i][0] = max(dp[i-1][0], max(dp[i-1][1], dp[i-1][2]));
}
/*for(long long i = 0; i < dp.size(); i ++){
cout << dp[i][0] << " ";
}*/
return max(dp[N-1][1], dp[N-1][0]);
//sort(fish.begin(), fish.end());
}
/*
g++ -std=gnu++17 -O2 -Wall -pipe -static -o fish grader.cpp fish.cpp
6 6
0 0 4
1 0 2
2 0 3
3 0 1
4 0 5
5 0 3
4 2 3 1 5 3
*/
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... |