이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, ans=0;
cin >> n;
int x[100000], g[100000], d[100000];
map<int,int> prefg, prefd;
for(int i = 0; i < n; i++) {
cin >> x[i] >> g[i] >> d[i];
prefg[x[i]] = g[i];
prefd[x[i]] = d[i];
if(i) {
prefg[x[i]] += prefg[x[i-1]];
}
if(i) {
prefd[x[i]] += prefd[x[i-1]];
}
}
for(int i = 0; i < n; i++) {
for(int j = i; j < n; j++) {
int len = x[j] - x[i] + 1;
int power = prefd[x[j]];
if(i) {
power -= prefd[i-1];
}
if(power < len) continue;
int local_ans = prefg[x[j]];
if(i) {
local_ans -= prefg[x[i-1]];
}
ans = max(ans, local_ans);
}
}
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... |