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;
vector<int> B;
for (int i = 0 ; i < N ; i++){
int x , a , b ;
cin >> x >> a >> b;
v.push_back({x , a , b});
B.push_back(b);
}
B.push_back(1e18);
v.push_back({D , 0 , 0});
sort(v.begin() , v.end());
sort(B.begin() , B.end());
int ans = 1e18;
for (int F = 0 ; F <= N ; F++){
int mn = 0;
int sum = 0;
for (int i = 0 ; i <= N ; i++){
mn = min(mn , sum - v[i][0]);
if (B[F] <= v[i][2]) sum += v[i][1];
}
if (-mn <= B[F]) ans = min(ans , -mn);
}
cout << ans;
}
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... |