Submission #657248

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
6572482022-11-09 10:52:49lumibonsCatfish Farm (IOI22_fish)C++17
100 / 100
481 ms60260 KiB
#include "fish.h"
#include <bits/stdc++.h>
using namespace std;
#define sz(x) ((int) (x).size())
typedef long long ll;
ll max_weights(int n, int m, vector<int> x, vector<int> y, vector<int> w) {
vector<vector<int>> p(n + 3);
for (int i = 0; i < m; i++)
for (int d = x[i] == 0 ? 0 : -1; d < (x[i] == n - 1 ? 1 : 2); d++)
p[x[i] + d + 1].push_back(y[i]);
vector<vector<ll>> ws(n + 3);
for (int i = 0; i < n + 3; i++) {
p[i].push_back(-1);
sort(p[i].begin(), p[i].end());
p[i].erase(unique(p[i].begin(), p[i].end()), p[i].end());
ws[i].resize(sz(p[i]));
}
for (int i = 0; i < m; i++) {
int j = (int) (lower_bound(p[x[i] + 1].begin(), p[x[i] + 1].end(), y[i]) - p[x[i] + 1].begin());
ws[x[i] + 1][j] += w[i];
}
for (int i = 0; i < n + 3; i++)
for (int j = 1; j < sz(ws[i]); j++)
ws[i][j] += ws[i][j - 1];
auto weightBelow = [&](int i, int j) {
int k = (int) (upper_bound(p[i].begin(), p[i].end(), j) - p[i].begin()) - 1;
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...