이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
//#define int long long
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<vector<long long >> vll;
typedef vector<long long> vl;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using ordered_set =
tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<class T> using ordered_multiset =
tree<T, null_type, greater_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
struct Rudnik {
int coordinate, gold, energy;
};
signed main() {
// cout.setf(ios::fixed);
// cout.precision(0);
ios_base::sync_with_stdio(false);
cout.tie(NULL);
cin.tie(NULL);
int n;
cin >> n;
vector<Rudnik> arr(n);
for (int i = 0; i < n; ++i) {
cin >> arr[i].coordinate >> arr[i].gold >> arr[i].energy;
}
int ans = 0;
for (int i = 0; i < n; ++i) {
int tmp = arr[i].gold;
int energy = arr[i].energy;
int size = 0;
for (int j = i+1; j < n; ++j) {
if (size <= energy){
ans = max(ans, tmp);
}
tmp += arr[j].gold;
energy += arr[j].energy;
size += arr[j].coordinate - arr[j-1].coordinate;
}
if (size <= energy){
ans = max(ans, tmp);
}
}
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... |