/*
Code written by Talant I.D.
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef tuple <int, int, int> tiii;
#define precision(n) fixed << setprecision(n)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define mt make_tuple
#define mod (int)1e9+7
#define eps (double)1e-9
#define PI 2*acos(-0.0);
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define do_not_disturb ios::sync_with_stdio(0);cin.tie(0);
#define curMod 998244353
inline bool isvowel(char ch){
ch = tolower(ch);
return (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u');
}
bool isprime(int n){
if(n < 2 || (n % 2 == 0 && n != 2))
return false;
for(int i = 3; i*i <= n; i += 2)
if(n % i == 0) return false;
return true;
}
int main(){
do_not_disturb
ll n, i, mx = 0ll, l = 1ll, r = 0ll;
cin >> n;
vector <ll> en(n+1), gold(n+1), pos(n+1);
en[0] = gold[0] = 0ll;
for(i = 1; i <= n; i++){
cin >> pos[i] >> gold[i] >> en[i];
}
for(i = 1; i <= n; i++){
en[i] += en[i-1];
gold[i] += gold[i-1];
}
while(r+1 <= n){
if(en[r+1]-en[l-1] >= abs(pos[r+1]-pos[l])){
r++;
mx = max(mx, gold[r]-gold[l-1]);
}
else{
l++;
mx = max(mx, gold[r]-gold[l-1]);
}
}
cout << mx;
return 0;
} // What is to be written here?
# |
결과 |
실행 시간 |
메모리 |
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 |
380 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 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
504 KB |
Output is correct |
2 |
Correct |
5 ms |
632 KB |
Output is correct |
3 |
Correct |
5 ms |
504 KB |
Output is correct |
4 |
Correct |
19 ms |
1532 KB |
Output is correct |
5 |
Correct |
22 ms |
1528 KB |
Output is correct |
6 |
Correct |
47 ms |
2680 KB |
Output is correct |
7 |
Correct |
35 ms |
2744 KB |
Output is correct |
8 |
Correct |
36 ms |
2684 KB |
Output is correct |
9 |
Correct |
34 ms |
2680 KB |
Output is correct |
10 |
Incorrect |
35 ms |
2680 KB |
Output isn't correct |
11 |
Halted |
0 ms |
0 KB |
- |