This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <fstream>
#include <string>
#include <random>
#include <chrono>
#include <memory.h>
using namespace std;
using ll = long long;
int main()
{
//freopen("divide.in", "r", stdin);
//freopen("divide.out", "w", stdout);
int n;
cin>>n;
set<pair<ll, ll>>st;
ll gold = 0, energy = 0, ans = 0;
for(int i = 0; i < n; i++){
ll x,g,d;
cin>>x>>g>>d;
st.insert(make_pair(x - energy, gold));
gold += g, energy += d;
auto it = st.lower_bound(make_pair(x - energy, 0ll));
if(it != st.end()){
ans = max(ans, gold - it->second);
}
}
cout<<ans<<'\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |