#include "fish.h"
#include<bits/stdc++.h>
using namespace std;
#define ll long long// !
#define sz(a) (int)a.size()
#define all(a) a.begin(),a.end()
#define F first
#define S second
const int MAXN = 1e5 + 3;
ll max_weights(int n, int m, vector<int> X, std::vector<int> Y, vector<int> W) {
// dp[i][j], for i'th column just before the j'th element
vector<pair<int, int>> pos[n+1];
for (int i = 0; i < m; i++){
pos[X[i]+1].push_back({Y[i], W[i]});
}
vector<vector<ll>> dp(n+1);
for (int i = 0; i <= n; i++){
pos[i].push_back({MAXN, 0});
sort(all(pos[i]));
dp[i].resize(sz(pos[i]), 0ll);
}
for (int i = 1; i <= n; i++){
for (int j = 0; j < sz(dp[i]); j++){
ll& me = dp[i][j];
ll cnt = 0;
for (int k = sz(dp[i - 1]) - 1; k >= 0; k--){
if (pos[i-1][k].F <= pos[i][j].F-1) cnt += pos[i-1][k].S;
me = max(me, cnt + dp[i-1][k]);
}
}
}
ll ans = 0;
for (auto it : dp[n]){
ans = max(ans, it);
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
37 ms |
13408 KB |
Output is correct |
2 |
Correct |
42 ms |
15292 KB |
Output is correct |
3 |
Correct |
13 ms |
11356 KB |
Output is correct |
4 |
Correct |
12 ms |
11356 KB |
Output is correct |
5 |
Correct |
111 ms |
22924 KB |
Output is correct |
6 |
Correct |
104 ms |
26772 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Execution timed out |
1070 ms |
16560 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
11356 KB |
Output is correct |
2 |
Incorrect |
13 ms |
11356 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 |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 1st token, expected: '4044', found: '2022' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 1st token, expected: '4044', found: '2022' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 1st token, expected: '4044', found: '2022' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
11356 KB |
Output is correct |
2 |
Incorrect |
13 ms |
11356 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 |
37 ms |
13408 KB |
Output is correct |
2 |
Correct |
42 ms |
15292 KB |
Output is correct |
3 |
Correct |
13 ms |
11356 KB |
Output is correct |
4 |
Correct |
12 ms |
11356 KB |
Output is correct |
5 |
Correct |
111 ms |
22924 KB |
Output is correct |
6 |
Correct |
104 ms |
26772 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Execution timed out |
1070 ms |
16560 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |