This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define int long long
void doWork(){
int N , D;
cin >> N >> D;
vector<array<int, 3>> v;
for (int i = 0 ; i < N ; i++){
int x , a , b ;
cin >> x >> a >> b;
v.push_back({x , a , b});
}
v.push_back({D , 0 , 0});
sort(v.begin() , v.end());
for (int F = 0 ; F <= D ; F++){
bool f = 1;
int sum = F;
for (int i = 0 ; i <= N ; i++){
if (sum - v[i][0] < 0) {f = 0; break;}
if (F <= v[i][2]) sum += v[i][1];
}
if (f) {cout << F; break;}
}
}
signed main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
doWork();
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |