이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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<array<int , 3>> B;
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 i = 0 ; i < N ; i++){
B.push_back({v[i][2], v[i][1] , i});
}
sort(B.begin() , B.end());
int x[N+1] = {};
for (int i = 0 ; i <= N ; i++){
x[i] = - v[i][0];
}
int ans = 1e18;
for (int F = 0 ; F < N ; F++){
for (int j = B[F][2] + 1 ; j <= N ; j++) x[j] += B[F][1];
int mn = 0;
for (int j = 0 ; j <= N ; j++) {mn = min(mn , x[j]); }
if (-mn <= B[F][0]) 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... |