#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define bas(x) #x << ": " << x << " "
#define prarr(x, n) cout << #x << ": "; for (int qsd = 0; qsd < n; qsd++) cout << x[qsd] << " "; cout << endl;
#define prarrv(x) cout << #x << ": "; for (int qsd = 0; qsd < (int)x.size(); qsd++) cout << x[qsd] << " "; cout << endl;
#define inside sl<=l%&&r<=sr
#define outside sr<l||r<sl
typedef long long ll;
struct node {
ll a, b, top;
};
node a[200002];
node b[200002];
int n, m;
ll dp[2002][2002];
ll get(int kim, int dayi){
if (dayi == -1) return 0;
else if (kim == 0) return a[dayi].top;
else return b[dayi].top;
}
int main(){
cin >> n >> m;
ll cur = 0;
for (int i = 0; i < n; i++){
ll x, y, c;
cin >> x >> y >> c;
cur += x;
a[i] = {x, y, cur};
}
cur = 0;
for (int i = 0; i < m; i++){
ll x, y, c;
cin >> x >> y >> c;
cur += x;
b[i] = {x, y, cur};
}
for (int i = 0; i <= n; i++)
for (int j = 0; j <= m; j++)
dp[i][j] = -1;
dp[0][0] = 0;
for (int i = 0; i <= n; i++){
for (int j = 0; j <= m; j++){
//cout << dp[i][j] << " ";
if (i != n) dp[i+1][j] = max(dp[i+1][j], dp[i][j] + ((get(0, i) + get(1, j-1) <= a[i].b) ? 1 : 0));
if (j != m) dp[i][j+1] = max(dp[i][j+1], dp[i][j] + ((get(0, i-1) + get(1, j) <= b[j].b) ? 1 : 0));
}
//cout << endl;
}
//cout << endl;
cout << dp[n][m] << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1337 ms |
84428 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
372 KB |
Output is correct |
15 |
Correct |
2 ms |
312 KB |
Output is correct |
16 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
372 KB |
Output is correct |
15 |
Correct |
2 ms |
312 KB |
Output is correct |
16 |
Correct |
2 ms |
376 KB |
Output is correct |
17 |
Correct |
53 ms |
31992 KB |
Output is correct |
18 |
Correct |
52 ms |
31864 KB |
Output is correct |
19 |
Correct |
51 ms |
31936 KB |
Output is correct |
20 |
Correct |
54 ms |
31864 KB |
Output is correct |
21 |
Correct |
50 ms |
30712 KB |
Output is correct |
22 |
Correct |
49 ms |
31864 KB |
Output is correct |
23 |
Correct |
49 ms |
31864 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
372 KB |
Output is correct |
15 |
Correct |
2 ms |
312 KB |
Output is correct |
16 |
Correct |
2 ms |
376 KB |
Output is correct |
17 |
Correct |
53 ms |
31992 KB |
Output is correct |
18 |
Correct |
52 ms |
31864 KB |
Output is correct |
19 |
Correct |
51 ms |
31936 KB |
Output is correct |
20 |
Correct |
54 ms |
31864 KB |
Output is correct |
21 |
Correct |
50 ms |
30712 KB |
Output is correct |
22 |
Correct |
49 ms |
31864 KB |
Output is correct |
23 |
Correct |
49 ms |
31864 KB |
Output is correct |
24 |
Runtime error |
1179 ms |
93484 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
25 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
372 KB |
Output is correct |
15 |
Correct |
2 ms |
312 KB |
Output is correct |
16 |
Correct |
2 ms |
376 KB |
Output is correct |
17 |
Correct |
53 ms |
31992 KB |
Output is correct |
18 |
Correct |
52 ms |
31864 KB |
Output is correct |
19 |
Correct |
51 ms |
31936 KB |
Output is correct |
20 |
Correct |
54 ms |
31864 KB |
Output is correct |
21 |
Correct |
50 ms |
30712 KB |
Output is correct |
22 |
Correct |
49 ms |
31864 KB |
Output is correct |
23 |
Correct |
49 ms |
31864 KB |
Output is correct |
24 |
Runtime error |
1179 ms |
93484 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
25 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
372 KB |
Output is correct |
15 |
Correct |
2 ms |
312 KB |
Output is correct |
16 |
Correct |
2 ms |
376 KB |
Output is correct |
17 |
Correct |
53 ms |
31992 KB |
Output is correct |
18 |
Correct |
52 ms |
31864 KB |
Output is correct |
19 |
Correct |
51 ms |
31936 KB |
Output is correct |
20 |
Correct |
54 ms |
31864 KB |
Output is correct |
21 |
Correct |
50 ms |
30712 KB |
Output is correct |
22 |
Correct |
49 ms |
31864 KB |
Output is correct |
23 |
Correct |
49 ms |
31864 KB |
Output is correct |
24 |
Runtime error |
1179 ms |
93484 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
25 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1337 ms |
84428 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1337 ms |
84428 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |