이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define maxn 100010
using namespace std;
int n, ans, p[maxn], eSum[maxn], goldSum[maxn], g[maxn], e[maxn], sufM;
vector<pair<int, int> > sufV;
int main(){
ios_base::sync_with_stdio(0);
cout.tie(0);
cin.tie(0);
cin >> n;
for(int i = 1; i <= n; ++i){
cin >> p[i] >> g[i] >> e[i];
goldSum[i] = goldSum[i-1]+g[i];
eSum[i] = eSum[i-1] + e[i];
}
sufM = -1e9;
for(int i = n; i > 0; --i){
sufM = max(sufM, eSum[i]-p[i]);
sufV.push_back(make_pair(sufM,i));
int tmp = (*(lower_bound(sufV.begin(), sufV.end(), make_pair(eSum[i-1]-p[i], 0)))).second;
//cerr << tmp << '\n';
ans = max(ans, goldSum[tmp]-goldSum[i-1]);
}
cout << ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |