#include <bits/stdc++.h>
#define ll long long
#define vt vector
#define pb push_back
#define ar array
#define all(x) (x).begin(), (x).end()
#define sz(x) (x).size()
using namespace std;
/*
## TAKE IT EASY ##
1. simplify
2. add new elements
3. brute force solution
4. optimize
5. start implementing
*/
// --- templates ---
// --- code ---
//const int N = 300 + 10;
const int N = 100000 + 10;
ll dp[N][2][10];
ll max_weights(int n, int m, vt<int> X, vt<int> Y, vt<int> W){
memset(dp, 0, sizeof dp);
int h = 10;
vt<vt<ll>> a(n + 5, vt<ll>(h));
for(int i = 0; i < m; i++){
a[X[i]][Y[i] + 1] = W[i];
}
for(int i = 0; i < n; i++){
for(int j = 1; j < h; j++){
a[i][j] += a[i][j - 1];
}
}
for(int i = 0; i < n; i++){
for(int flow = 0; flow < 2; flow++){
for(int h1 = 0; h1 < h; h1++){
for(int h2 = 0; h2 < (flow ? h : h1 + 1); h2++){
int nflow = h1 <= h2;
ll l = 0, r = a[i + 1][h2], sub = a[i][min(h1, h2)];
if(i == 0){
dp[i][nflow][h2] = max(dp[i][nflow][h2], r);
}else{
l = max((ll)0, a[i - 1][h2] - a[i - 1][h1]);
dp[i][nflow][h2] = max(dp[i][nflow][h2], l + dp[i - 1][flow][h1] + r - sub);
}
}
}
}
}
ll ans = 0;
for(int flow = 0; flow < 2; flow++){
for(int h1 = 0; h1 < h; h1++){
ans = max(ans, dp[n - 1][flow][h1]);
}
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
100 ms |
58804 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
15956 KB |
Output is correct |
2 |
Runtime error |
123 ms |
63672 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
61 ms |
27604 KB |
Output is correct |
2 |
Correct |
67 ms |
27712 KB |
Output is correct |
3 |
Incorrect |
72 ms |
28728 KB |
1st lines differ - on the 1st token, expected: '21261825233649', found: '20897672610412' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
15956 KB |
Output is correct |
2 |
Correct |
7 ms |
15920 KB |
Output is correct |
3 |
Correct |
7 ms |
15928 KB |
Output is correct |
4 |
Correct |
7 ms |
15908 KB |
Output is correct |
5 |
Correct |
7 ms |
15956 KB |
Output is correct |
6 |
Correct |
7 ms |
15924 KB |
Output is correct |
7 |
Correct |
7 ms |
15916 KB |
Output is correct |
8 |
Correct |
7 ms |
15956 KB |
Output is correct |
9 |
Incorrect |
11 ms |
15956 KB |
1st lines differ - on the 1st token, expected: '216624184325', found: '214837477243' |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
15956 KB |
Output is correct |
2 |
Correct |
7 ms |
15920 KB |
Output is correct |
3 |
Correct |
7 ms |
15928 KB |
Output is correct |
4 |
Correct |
7 ms |
15908 KB |
Output is correct |
5 |
Correct |
7 ms |
15956 KB |
Output is correct |
6 |
Correct |
7 ms |
15924 KB |
Output is correct |
7 |
Correct |
7 ms |
15916 KB |
Output is correct |
8 |
Correct |
7 ms |
15956 KB |
Output is correct |
9 |
Incorrect |
11 ms |
15956 KB |
1st lines differ - on the 1st token, expected: '216624184325', found: '214837477243' |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
15956 KB |
Output is correct |
2 |
Correct |
7 ms |
15920 KB |
Output is correct |
3 |
Correct |
7 ms |
15928 KB |
Output is correct |
4 |
Correct |
7 ms |
15908 KB |
Output is correct |
5 |
Correct |
7 ms |
15956 KB |
Output is correct |
6 |
Correct |
7 ms |
15924 KB |
Output is correct |
7 |
Correct |
7 ms |
15916 KB |
Output is correct |
8 |
Correct |
7 ms |
15956 KB |
Output is correct |
9 |
Incorrect |
11 ms |
15956 KB |
1st lines differ - on the 1st token, expected: '216624184325', found: '214837477243' |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
61 ms |
27604 KB |
Output is correct |
2 |
Correct |
67 ms |
27712 KB |
Output is correct |
3 |
Incorrect |
72 ms |
28728 KB |
1st lines differ - on the 1st token, expected: '21261825233649', found: '20897672610412' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
100 ms |
58804 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |