# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1106943 | I_am_Polish_Girl | Catfish Farm (IOI22_fish) | C++17 | 1091 ms | 10680 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.
/*
In honor of Anton Tsypko
I want earrings with minecreaft
I want earrings with birbie
*/
#include "fish.h"
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <cmath>
#include <random>
#include <chrono>
#include <iomanip>
#include <iostream>
#include <bitset>
#include <cmath>
#include <string>
using namespace std;
int log_ = 23;
int inf = 2000000007;
int mod = 1000000007;
int p = 523;
#include <vector>
long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y, std::vector<int> W)
{
int n = N;
vector <vector <pair <int, int>>> vp(n);
for (int i = 0; i < X.size(); i++)
{
vp[X[i]].push_back({ Y[i] , W[i] });
}
for (int i = 0; i < n; i++)
{
sort(vp[i].begin(), vp[i].end());
}
vector <int> dp(n);
int mx = 0;
for (int i = 0; i < n ; i++)
{
vector <vector <int>> dp_;
dp_.resize(n);
for (int j = 0; j < n; j++)
{
dp_[j].resize(vp[j].size());
}
int c = mx;
for (int j = i; j < n; j++)
{
int ind = -1;
int mx_ = 0;
for (int k = 0; k < vp[j].size(); k++)
{
if (j == i)
{
mx_ += vp[j][k].second;
dp_[j][k] = mx_;
dp[i] = max(dp[i], mx_ + c);
continue;
}
while ((ind + 1 != vp[j - 1].size()) and (vp[j - 1][ind + 1].first < vp[j][k].first))
{
mx_ = max(mx_, dp_[j - 1][ind + 1]);
ind++;
}
if (mx_ == 0)
continue;
dp_[j][k] = mx_ + vp[j][k].second;
mx_ = max(mx_, dp_[j][k]);
if (j != n - 1)
dp[j] = max(dp[j], mx_ + c);
}
if (vp[i].size() == 0)
break;
}
dp_.clear();
dp_.resize(n);
for (int j = 0; j < n; j++)
{
dp_[j].resize(vp[j].size());
}
if (i != 0)
{
for (int j = i; j < n; j++)
{
int ind = vp[j].size();
int mx_ = 0;
int sz = vp[j].size();
for (int k = sz - 1; k >= 0; k--)
{
dp_[j][k] = 0;
if (j == i)
{
mx_ += vp[j][k].second;
dp_[j][k] = mx_;
dp[i] = max(dp[i], mx_ + c);
continue;
}
while ((ind - 1 >= 0) and (vp[j - 1][ind - 1].first > vp[j][k].first))
{
mx_ = max(mx_, dp_[j - 1][ind - 1]);
ind--;
}
if (mx_ == 0)
continue;
dp_[j][k] = mx_ + vp[j][k].second;
mx_ = max(mx_, dp_[j][k]);
if (j != n - 1)
dp[j] = max(dp[j], mx_ + c);
}
if (vp[i].size() == 0)
break;
}
}
if (i - 1 >= 0)
mx = max(dp[i - 1], mx);
}
int ans = 0;
for (int i = 0; i < n; i++)
{
ans = max(ans, dp[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... |