이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <utility>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <cstring>
int x;
int diff_coords[100005];
int coords[100005];
int arr1[100005];
int arr2[100005];
int main() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(NULL);
std::cout.tie(NULL);
std::cin >> x;
for (int i = 1; i <= x; i++) {
int a, b, c;
std::cin >> a >> b >> c;
coords[i] = a;
diff_coords[i] = a - diff_coords[i-1];
arr1[i] = c;
arr2[i] = b;
}
int64_t ans = 0;
for (int i = 1; i <= x; i++) {
int64_t gold = arr2[i];
int64_t diff = arr1[i];
ans = std::max(ans,gold);
for (int j = i-1; j >= 1; j--) {
gold += arr2[j];
diff += arr1[j];
diff -= diff_coords[j+1];
if (diff>=0) {
ans = std::max(ans,gold);
}
}
}
std::cout << ans << "\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... |