# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
703176 |
2023-02-26T12:40:28 Z |
n1k |
메기 농장 (IOI22_fish) |
C++17 |
|
1000 ms |
2097152 KB |
#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 = 3000 + 10, FLOW = 3;
ll dp[N][FLOW][N];
ll max_weights(int n, int m, vt<int> X, vt<int> Y, vt<int> W){
memset(dp, 0, sizeof dp);
int h = n + 5;
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 < FLOW; flow++){
for(int h1 = 0; h1 < h; h1++){
for(int h2 = 0; h2 < (flow == 0 ? h1 + 1 : h); h2++){
int nflow = h1 <= h2;
if(i == 0){
dp[i][nflow][h2] = max(dp[i][nflow][h2], a[i + 1][h2]);
}else{
if(flow == 0){
dp[i][nflow][h2] = max(dp[i][nflow][h2], dp[i - 1][flow][h1] + a[i + 1][h2] - a[i][h2]);
}else if(flow == 1){
dp[i][nflow][h2] = max(dp[i][nflow][h2], dp[i - 1][flow][h1] + a[i + 1][h2] + max((ll)0, (a[i - 1][h2] - a[i - 1][h1])) - min(a[i][h1], a[i][h2]));
}else{
nflow = 1;
dp[i][nflow][h2] = max(dp[i][nflow][h2], dp[i - 1][flow][h1] + a[i + 1][h2] + max((ll)0, (a[i - 1][h2] - a[i - 1][h1])));
}
}
}
if(i)
dp[i][2][h1] = max(dp[i - 1][0][h1], dp[i - 1][1][h1]);
}
}
}
ll ans = 0;
for(int flow = 0; flow < FLOW; flow++){
for(int h1 = 0; h1 < h; h1++){
ans = max(ans, dp[n - 1][flow][h1]);
}
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1032 ms |
2097152 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
88 ms |
212940 KB |
Output is correct |
2 |
Runtime error |
916 ms |
2097152 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
751 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
92 ms |
212980 KB |
Output is correct |
2 |
Correct |
88 ms |
213036 KB |
Output is correct |
3 |
Correct |
99 ms |
212948 KB |
Output is correct |
4 |
Correct |
89 ms |
212940 KB |
Output is correct |
5 |
Correct |
94 ms |
212960 KB |
Output is correct |
6 |
Correct |
95 ms |
212948 KB |
Output is correct |
7 |
Correct |
88 ms |
212940 KB |
Output is correct |
8 |
Correct |
87 ms |
213044 KB |
Output is correct |
9 |
Correct |
129 ms |
213304 KB |
Output is correct |
10 |
Correct |
321 ms |
213876 KB |
Output is correct |
11 |
Correct |
115 ms |
213220 KB |
Output is correct |
12 |
Correct |
311 ms |
213828 KB |
Output is correct |
13 |
Correct |
92 ms |
213168 KB |
Output is correct |
14 |
Correct |
322 ms |
213816 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
92 ms |
212980 KB |
Output is correct |
2 |
Correct |
88 ms |
213036 KB |
Output is correct |
3 |
Correct |
99 ms |
212948 KB |
Output is correct |
4 |
Correct |
89 ms |
212940 KB |
Output is correct |
5 |
Correct |
94 ms |
212960 KB |
Output is correct |
6 |
Correct |
95 ms |
212948 KB |
Output is correct |
7 |
Correct |
88 ms |
212940 KB |
Output is correct |
8 |
Correct |
87 ms |
213044 KB |
Output is correct |
9 |
Correct |
129 ms |
213304 KB |
Output is correct |
10 |
Correct |
321 ms |
213876 KB |
Output is correct |
11 |
Correct |
115 ms |
213220 KB |
Output is correct |
12 |
Correct |
311 ms |
213828 KB |
Output is correct |
13 |
Correct |
92 ms |
213168 KB |
Output is correct |
14 |
Correct |
322 ms |
213816 KB |
Output is correct |
15 |
Correct |
306 ms |
213784 KB |
Output is correct |
16 |
Correct |
104 ms |
213072 KB |
Output is correct |
17 |
Correct |
357 ms |
215588 KB |
Output is correct |
18 |
Correct |
315 ms |
215676 KB |
Output is correct |
19 |
Correct |
384 ms |
215604 KB |
Output is correct |
20 |
Correct |
319 ms |
215604 KB |
Output is correct |
21 |
Correct |
334 ms |
215592 KB |
Output is correct |
22 |
Correct |
339 ms |
217416 KB |
Output is correct |
23 |
Correct |
323 ms |
214140 KB |
Output is correct |
24 |
Correct |
317 ms |
214988 KB |
Output is correct |
25 |
Correct |
339 ms |
213892 KB |
Output is correct |
26 |
Correct |
307 ms |
214136 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
92 ms |
212980 KB |
Output is correct |
2 |
Correct |
88 ms |
213036 KB |
Output is correct |
3 |
Correct |
99 ms |
212948 KB |
Output is correct |
4 |
Correct |
89 ms |
212940 KB |
Output is correct |
5 |
Correct |
94 ms |
212960 KB |
Output is correct |
6 |
Correct |
95 ms |
212948 KB |
Output is correct |
7 |
Correct |
88 ms |
212940 KB |
Output is correct |
8 |
Correct |
87 ms |
213044 KB |
Output is correct |
9 |
Correct |
129 ms |
213304 KB |
Output is correct |
10 |
Correct |
321 ms |
213876 KB |
Output is correct |
11 |
Correct |
115 ms |
213220 KB |
Output is correct |
12 |
Correct |
311 ms |
213828 KB |
Output is correct |
13 |
Correct |
92 ms |
213168 KB |
Output is correct |
14 |
Correct |
322 ms |
213816 KB |
Output is correct |
15 |
Correct |
306 ms |
213784 KB |
Output is correct |
16 |
Correct |
104 ms |
213072 KB |
Output is correct |
17 |
Correct |
357 ms |
215588 KB |
Output is correct |
18 |
Correct |
315 ms |
215676 KB |
Output is correct |
19 |
Correct |
384 ms |
215604 KB |
Output is correct |
20 |
Correct |
319 ms |
215604 KB |
Output is correct |
21 |
Correct |
334 ms |
215592 KB |
Output is correct |
22 |
Correct |
339 ms |
217416 KB |
Output is correct |
23 |
Correct |
323 ms |
214140 KB |
Output is correct |
24 |
Correct |
317 ms |
214988 KB |
Output is correct |
25 |
Correct |
339 ms |
213892 KB |
Output is correct |
26 |
Correct |
307 ms |
214136 KB |
Output is correct |
27 |
Execution timed out |
1102 ms |
283852 KB |
Time limit exceeded |
28 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
751 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1032 ms |
2097152 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |