// 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){
int 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){
for(int j = i; j <= n; ++j){
if(a[j] - a[i] <= c[j] - c[i - 1] && i > 1 || i == 1 && a[j] - a[j - 1]<= c[j] - c[i - 1]){
ans = max(ans, b[j] - b[i - 1]);
}
}
}
cout << ans << nl;
return 0;
}
Compilation message
divide.cpp: In function 'int main()':
divide.cpp:40:50: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
if(a[j] - a[i] <= c[j] - c[i - 1] && i > 1 || i == 1 && a[j] - a[j - 1]<= c[j] - c[i - 1]){
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
400 KB |
Output is correct |
2 |
Correct |
2 ms |
448 KB |
Output is correct |
3 |
Incorrect |
3 ms |
472 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
23 ms |
664 KB |
Output is correct |
2 |
Correct |
80 ms |
964 KB |
Output is correct |
3 |
Correct |
86 ms |
1156 KB |
Output is correct |
4 |
Execution timed out |
1068 ms |
3196 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |