// In the name of GOD
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;
#define BeGood ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define orset tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define nl '\n'
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pb push_back
typedef long long ll;
typedef double db;
const int N = 1e5 + 4;
const int M = 1e9 + 7;
int n;
long long g[N], e[N];
long long a[N];
long long ans;
int main(){
BeGood
cin >> n;
for(int i = 1; i <= n; ++i){
cin >> a[i];
int q, w;
cin >> q >> w;
g[i] = g[i - 1] + q;
e[i] = e[i - 1] + w;
}
for(int i = 1; i <= n; ++i){
for(int j = i; j <= n; ++j){
if(e[j] - e[i - 1] >= a[j] - a[i]){
ans = max(ans, g[j] - g[i - 1]);
}
}
}
cout << ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
3 ms |
384 KB |
Output is correct |
6 |
Correct |
3 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
3 ms |
384 KB |
Output is correct |
11 |
Correct |
2 ms |
384 KB |
Output is correct |
12 |
Correct |
3 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
384 KB |
Output is correct |
5 |
Correct |
3 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
3 ms |
384 KB |
Output is correct |
8 |
Correct |
3 ms |
384 KB |
Output is correct |
9 |
Correct |
4 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
488 KB |
Output is correct |
11 |
Correct |
15 ms |
640 KB |
Output is correct |
12 |
Correct |
15 ms |
640 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
512 KB |
Output is correct |
2 |
Correct |
67 ms |
888 KB |
Output is correct |
3 |
Correct |
98 ms |
888 KB |
Output is correct |
4 |
Execution timed out |
1062 ms |
2552 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |