#include "fish.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
vector <vector <pair <int, ll>>> fish;
vector <vector <ll>> pfx;
int n, m;
ll get_sum(int l, int r, int col) {
pair <int, ll> tp = {l, 0};
// for (auto j : fish[col])
// cout << j.first << '\n';
int it = upper_bound(fish[col].begin(), fish[col].end(), tp) - fish[col].begin();
it--;
// cout << "IT1: " << it << '\n';
tp.first = r;
int it2 = upper_bound(fish[col].begin(), fish[col].end(), tp) - fish[col].begin();
it2--;
// cout << "IT2: " << it2 << '\n';
return pfx[col][it2] - pfx[col][it];
}
vector <vector <ll>> dp;
ll max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W) {
n = N;
m = M;
fish.resize(N+1);
pfx.resize(N+1);
for (int i = 0; i < M; i++) {
fish[X[i] + 1].push_back({Y[i] + 1, W[i]});
}
// dp = vector <vector <ll>> (N+1, vector <ll> (N+1, -1));
for (int i = 1; i <= N; i++) {
fish[i].push_back({0, 0});
sort(fish[i].begin(), fish[i].end());
pfx[i].resize((int)fish[i].size() + 5, 1e18);
for (int j = 1; j < (int)fish[i].size(); j++)
pfx[i][j] = pfx[i][j-1] + fish[i][j].second;
}
// for (auto j : fish[0])
// cout << j.first << '\n';
// cout << get_sum(1, N+1, 1) << '\n';
return max(get_sum(1, N+1, 1), get_sum(1, N+1, 2));
// return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
30 ms |
18328 KB |
Output is correct |
2 |
Correct |
64 ms |
20784 KB |
Output is correct |
3 |
Correct |
11 ms |
14428 KB |
Output is correct |
4 |
Correct |
13 ms |
14440 KB |
Output is correct |
5 |
Incorrect |
91 ms |
34864 KB |
1st lines differ - on the 1st token, expected: '149814460735479', found: '0' |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
1st lines differ - on the 1st token, expected: '2', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
14428 KB |
Output is correct |
2 |
Incorrect |
19 ms |
14368 KB |
1st lines differ - on the 1st token, expected: '882019', found: '0' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 1st token, expected: '3', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 1st token, expected: '3', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 1st token, expected: '3', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
14428 KB |
Output is correct |
2 |
Incorrect |
19 ms |
14368 KB |
1st lines differ - on the 1st token, expected: '882019', found: '0' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
30 ms |
18328 KB |
Output is correct |
2 |
Correct |
64 ms |
20784 KB |
Output is correct |
3 |
Correct |
11 ms |
14428 KB |
Output is correct |
4 |
Correct |
13 ms |
14440 KB |
Output is correct |
5 |
Incorrect |
91 ms |
34864 KB |
1st lines differ - on the 1st token, expected: '149814460735479', found: '0' |
6 |
Halted |
0 ms |
0 KB |
- |