#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 100;
const int maxl = 11;
int n;
ll dp[maxn][maxl][maxl];
ll a[maxn][maxl];
ll pref[2][maxn];
long long max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W){
n = N;
if(*max_element(X.begin(), X.end()) <= 1 && n > 2){
for(int i = 0; i < M; i++){
Y[i]++;
pref[X[i]][Y[i]] += W[i];
}
for(int i = 1; i <= n; i++){
pref[0][i] += pref[0][i-1];
}
for(int i = n; i > 0; i--){
pref[1][i] += pref[1][i+1];
}
ll ans = 0;
for(int i = 0; i <= n; i++){
ans = max(ans, pref[0][i] + pref[1][i+1]);
}
return ans;
}
bool ok = 1;
ll sum = 0;
for(int i = 0; i < M; i++){
X[i]++; Y[i]++;
if(Y[i] <= 11){
a[X[i]][Y[i]] += W[i];
}
ok &= X[i] & 1;
sum += W[i];
}
if(ok) return sum;
for(int i = 1; i <= n; i++){
for(int j = 1; j <= 10; j++){
a[i][j] += a[i][j-1];
}
}
for(int c = 1; c <= n + 1; c++){
for(int i = 0; i <= 10; i++){
for(int j = 0; j <= 10; j++){
dp[c][i][j] = -(ll)1e18;
if(c == 1 && i == 0) dp[c][i][j] = 0;
}
}
}
for(int c = 2; c <= n + 1; c++){
for(int i = 0; i <= 10; i++){
for(int j = 0; j <= 10; j++){
for(int k = 0; k <= 10; k++){
ll x = dp[c-1][i][j];
if(max(i, k) > j){
x += a[c-1][max(i, k)] - a[c-1][j];
}
dp[c][j][k] = max(dp[c][j][k], x);
}
}
}
}
ll ans = 0;
for(int i = 0; i <= 10; i++){
ans = max(ans, dp[n+1][i][0]);
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
16 ms |
4956 KB |
Output is correct |
2 |
Correct |
19 ms |
5652 KB |
Output is correct |
3 |
Correct |
1 ms |
1884 KB |
Output is correct |
4 |
Correct |
1 ms |
1884 KB |
Output is correct |
5 |
Correct |
58 ms |
12936 KB |
Output is correct |
6 |
Correct |
60 ms |
14056 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
59 ms |
8024 KB |
Output is correct |
3 |
Correct |
40 ms |
9552 KB |
Output is correct |
4 |
Correct |
21 ms |
5144 KB |
Output is correct |
5 |
Correct |
17 ms |
5724 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
1884 KB |
Output is correct |
11 |
Correct |
1 ms |
1884 KB |
Output is correct |
12 |
Correct |
17 ms |
4952 KB |
Output is correct |
13 |
Correct |
19 ms |
5716 KB |
Output is correct |
14 |
Correct |
17 ms |
4956 KB |
Output is correct |
15 |
Correct |
19 ms |
5468 KB |
Output is correct |
16 |
Correct |
17 ms |
5068 KB |
Output is correct |
17 |
Correct |
17 ms |
5464 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1976 KB |
Output is correct |
2 |
Correct |
249 ms |
103568 KB |
Output is correct |
3 |
Correct |
204 ms |
95572 KB |
Output is correct |
4 |
Correct |
217 ms |
105044 KB |
Output is correct |
5 |
Correct |
263 ms |
107704 KB |
Output is correct |
6 |
Correct |
229 ms |
106952 KB |
Output is correct |
7 |
Correct |
234 ms |
107604 KB |
Output is correct |
8 |
Correct |
250 ms |
107440 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
444 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
604 KB |
Output is correct |
10 |
Correct |
1 ms |
860 KB |
Output is correct |
11 |
Correct |
1 ms |
604 KB |
Output is correct |
12 |
Correct |
1 ms |
604 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
604 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
444 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
604 KB |
Output is correct |
10 |
Correct |
1 ms |
860 KB |
Output is correct |
11 |
Correct |
1 ms |
604 KB |
Output is correct |
12 |
Correct |
1 ms |
604 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
604 KB |
Output is correct |
15 |
Incorrect |
2 ms |
604 KB |
1st lines differ - on the 1st token, expected: '299', found: '10' |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
444 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
604 KB |
Output is correct |
10 |
Correct |
1 ms |
860 KB |
Output is correct |
11 |
Correct |
1 ms |
604 KB |
Output is correct |
12 |
Correct |
1 ms |
604 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
604 KB |
Output is correct |
15 |
Incorrect |
2 ms |
604 KB |
1st lines differ - on the 1st token, expected: '299', found: '10' |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1976 KB |
Output is correct |
2 |
Correct |
249 ms |
103568 KB |
Output is correct |
3 |
Correct |
204 ms |
95572 KB |
Output is correct |
4 |
Correct |
217 ms |
105044 KB |
Output is correct |
5 |
Correct |
263 ms |
107704 KB |
Output is correct |
6 |
Correct |
229 ms |
106952 KB |
Output is correct |
7 |
Correct |
234 ms |
107604 KB |
Output is correct |
8 |
Correct |
250 ms |
107440 KB |
Output is correct |
9 |
Incorrect |
245 ms |
107308 KB |
1st lines differ - on the 1st token, expected: '99999', found: '10' |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
16 ms |
4956 KB |
Output is correct |
2 |
Correct |
19 ms |
5652 KB |
Output is correct |
3 |
Correct |
1 ms |
1884 KB |
Output is correct |
4 |
Correct |
1 ms |
1884 KB |
Output is correct |
5 |
Correct |
58 ms |
12936 KB |
Output is correct |
6 |
Correct |
60 ms |
14056 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
59 ms |
8024 KB |
Output is correct |
9 |
Correct |
40 ms |
9552 KB |
Output is correct |
10 |
Correct |
21 ms |
5144 KB |
Output is correct |
11 |
Correct |
17 ms |
5724 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
1884 KB |
Output is correct |
17 |
Correct |
1 ms |
1884 KB |
Output is correct |
18 |
Correct |
17 ms |
4952 KB |
Output is correct |
19 |
Correct |
19 ms |
5716 KB |
Output is correct |
20 |
Correct |
17 ms |
4956 KB |
Output is correct |
21 |
Correct |
19 ms |
5468 KB |
Output is correct |
22 |
Correct |
17 ms |
5068 KB |
Output is correct |
23 |
Correct |
17 ms |
5464 KB |
Output is correct |
24 |
Correct |
1 ms |
1976 KB |
Output is correct |
25 |
Correct |
249 ms |
103568 KB |
Output is correct |
26 |
Correct |
204 ms |
95572 KB |
Output is correct |
27 |
Correct |
217 ms |
105044 KB |
Output is correct |
28 |
Correct |
263 ms |
107704 KB |
Output is correct |
29 |
Correct |
229 ms |
106952 KB |
Output is correct |
30 |
Correct |
234 ms |
107604 KB |
Output is correct |
31 |
Correct |
250 ms |
107440 KB |
Output is correct |
32 |
Correct |
1 ms |
348 KB |
Output is correct |
33 |
Correct |
0 ms |
444 KB |
Output is correct |
34 |
Correct |
0 ms |
344 KB |
Output is correct |
35 |
Correct |
0 ms |
348 KB |
Output is correct |
36 |
Correct |
1 ms |
348 KB |
Output is correct |
37 |
Correct |
1 ms |
348 KB |
Output is correct |
38 |
Correct |
0 ms |
348 KB |
Output is correct |
39 |
Correct |
0 ms |
348 KB |
Output is correct |
40 |
Correct |
1 ms |
604 KB |
Output is correct |
41 |
Correct |
1 ms |
860 KB |
Output is correct |
42 |
Correct |
1 ms |
604 KB |
Output is correct |
43 |
Correct |
1 ms |
604 KB |
Output is correct |
44 |
Correct |
0 ms |
348 KB |
Output is correct |
45 |
Correct |
1 ms |
604 KB |
Output is correct |
46 |
Incorrect |
2 ms |
604 KB |
1st lines differ - on the 1st token, expected: '299', found: '10' |
47 |
Halted |
0 ms |
0 KB |
- |