// turmak-_-
#include<bits/stdc++.h>
#pragma optimize ("g",on)
#pragma GCC optimize("O3")
#pragma GCC target ("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#define all(v) v.begin(),v.end()
#define sz(a) a.size()
#define nl "\n"
#define IOI return 0;
#define pb push_back
#define ppb pop_back()
#define ll long long
#define ull unsigned long long
#define ld long double
#define IOS ios_base :: sync_with_stdio(NULL); cin.tie(0); cout.tie(0);
#define pii pair<int,int>
#define X first
#define Y second
using namespace std;
const int N = (int)1e5 + 7 ;
const ll MOD = (ll)998244353;
const ll INF = (ll)1e18 + 7;
const int inf = (int)1e9 + 7;
pii dx[] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
ll x[N],g[N],d[N],p[N],p1[N],p2[N];
void solve() {
int n;
cin>>n;
for(int i=1; i<=n; ++i) {
cin>>x[i]>>g[i]>>d[i];
p[i]=p[i-1] + g[i];
p1[i]=p1[i-1] + d[i];
}
ll mx = 0;
for(int i=1; i<=n; ++i) {
int l = i, r = n;
int ans = i;
while(l<=r) {
int mid = (l+r)>>1;
ll len = x[mid]-x[i-1];
ll power = p1[mid]-p1[i-1];
if(power>=len) {
ans = mid;
l = mid+1;
} else {
r = mid-1;
}
}
mx = max(mx, p[ans]-p[i-1]);
}
cout<<mx;
}
int main() {
IOS
//freopen("cinema.in", "r", stdin);
//freopen("cinema.out", "w", stdout);
int tt=1;
// cin>>tt;
while(tt--) {
solve();
}
IOI
}
Compilation message
divide.cpp:4: warning: ignoring #pragma optimize [-Wunknown-pragmas]
4 | #pragma optimize ("g",on)
|
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |