#include <bits/stdc++.h>
using namespace std;
#define int long long
const int mxN = (int)1e6+10;
const int LINF = (int)2e18;
int n, m;
int a[2][mxN], s[2][mxN], p[2][mxN], pr[2][mxN], pr2[2][mxN];
int32_t main(){
ios_base::sync_with_stdio(false); cin.tie(0);
cin >> n >> m; int ans = -LINF;
for(int j : {0,1}){
for(int i = 1; i <= n; i++){
cin >> a[j][i] >> s[j][i] >> p[j][i];
pr[j][i]=pr[j][i-1]+a[j][i];
pr2[j][i]=pr2[j][i-1]+p[j][i];
}
swap(n,m);
}
for(int j : {0,1}){
for(int i = 0; i <= n; i++){
if(pr[j][i]>s[j][1]) break;
int l = 0, r = m;
while(l<r){
int mid = (l+r+1)/2;
if(pr[j^1][mid]+pr[j][i]<=s[j][1])l=mid;
else r=mid-1;
}
ans = max(ans, pr2[j][i]+pr2[j^1][l]);
}
swap(n,m);
}
cout << ans << "\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
124 ms |
16040 KB |
Output is correct |
2 |
Correct |
123 ms |
29592 KB |
Output is correct |
3 |
Correct |
115 ms |
29404 KB |
Output is correct |
4 |
Correct |
119 ms |
29504 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
116 ms |
28692 KB |
Output is correct |
7 |
Correct |
53 ms |
14916 KB |
Output is correct |
8 |
Correct |
60 ms |
15140 KB |
Output is correct |
9 |
Correct |
116 ms |
30404 KB |
Output is correct |
10 |
Correct |
95 ms |
23412 KB |
Output is correct |
11 |
Correct |
80 ms |
23804 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
124 ms |
16040 KB |
Output is correct |
2 |
Correct |
123 ms |
29592 KB |
Output is correct |
3 |
Correct |
115 ms |
29404 KB |
Output is correct |
4 |
Correct |
119 ms |
29504 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
116 ms |
28692 KB |
Output is correct |
7 |
Correct |
53 ms |
14916 KB |
Output is correct |
8 |
Correct |
60 ms |
15140 KB |
Output is correct |
9 |
Correct |
116 ms |
30404 KB |
Output is correct |
10 |
Correct |
95 ms |
23412 KB |
Output is correct |
11 |
Correct |
80 ms |
23804 KB |
Output is correct |
12 |
Incorrect |
0 ms |
340 KB |
Output isn't correct |
13 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
124 ms |
16040 KB |
Output is correct |
2 |
Correct |
123 ms |
29592 KB |
Output is correct |
3 |
Correct |
115 ms |
29404 KB |
Output is correct |
4 |
Correct |
119 ms |
29504 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
116 ms |
28692 KB |
Output is correct |
7 |
Correct |
53 ms |
14916 KB |
Output is correct |
8 |
Correct |
60 ms |
15140 KB |
Output is correct |
9 |
Correct |
116 ms |
30404 KB |
Output is correct |
10 |
Correct |
95 ms |
23412 KB |
Output is correct |
11 |
Correct |
80 ms |
23804 KB |
Output is correct |
12 |
Incorrect |
0 ms |
340 KB |
Output isn't correct |
13 |
Halted |
0 ms |
0 KB |
- |