// In the name of GOD
#include <bits/stdc++.h>
using namespace std;
#define good exit(0);
#define nl endl
#define ios ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()
#define pb push_back
#define bb begin()
#define ee end()
#define ff first
#define ss second
#define ll long long
#define db double
#define pii pair<int, int>
const int N = 1e5 + 55;
const int M = 1e9 + 7;
int n, m;
ll a[N], b[N], c[N];
ll ans;
int main(){
cin >> n;
for(int i = 1; i <= n; ++i){
ll q, w, e;
cin >> q >> w >> e;
a[i] = a[i - 1] + q;
b[i] = b[i - 1] + w;
c[i] = c[i - 1] + e;
}
for(int i = 1; i <= n; ++i){
ans = max(ans, b[i] - b[i - 1]);
int l = i + 1, r = n;
while(l <= r){
int m = (l + r) / 2;
if(a[m] - a[m - i] <= c[m] - c[i -1]){
ans = max(ans, b[m] - b[i - 1]);
l = m + 1;
} else{
r = m - 1;
}
}
}
cout << ans << nl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
468 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
484 KB |
Output is correct |
2 |
Correct |
2 ms |
524 KB |
Output is correct |
3 |
Incorrect |
2 ms |
524 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
524 KB |
Output is correct |
2 |
Correct |
18 ms |
732 KB |
Output is correct |
3 |
Correct |
14 ms |
748 KB |
Output is correct |
4 |
Correct |
64 ms |
1712 KB |
Output is correct |
5 |
Correct |
78 ms |
2964 KB |
Output is correct |
6 |
Correct |
153 ms |
7276 KB |
Output is correct |
7 |
Correct |
145 ms |
8980 KB |
Output is correct |
8 |
Correct |
128 ms |
10992 KB |
Output is correct |
9 |
Correct |
141 ms |
12692 KB |
Output is correct |
10 |
Incorrect |
118 ms |
14404 KB |
Output isn't correct |
11 |
Halted |
0 ms |
0 KB |
- |