이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int maxn = 100100;
ll gold[maxn], energy[maxn], x[maxn], n;
ll prefix_g[maxn], prefix_e[maxn];
int main() {
cin>>n;
for(int i=1;i<=n;i++) {
cin>>x[i]>>gold[i]>>energy[i];
prefix_g[i] = prefix_g[i-1] + gold[i];
prefix_e[i] = prefix_e[i-1] + energy[i];
}
ll result = 0LL;
for(int i=1;i<=n;i++) {
for(int j=i;j>=1;j--) {
if(x[i] - x[j] <= prefix_e[i] - prefix_e[j-1]) {
result = max(result, prefix_g[i] - prefix_g[j-1]);
}
}
}
cout<<result<<"\n";
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |