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>
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define F first
#define S second
using namespace std;
const int N = 3e5 + 5;
void solve(){
ll n, len;
cin >> n >> len;
pair<ll, pair<ll, ll> > a[n + 2];
for(int i = 1; i <= n; ++i)
cin >> a[i].F >> a[i].S.F >> a[i].S.S;
a[0].F = 0;
a[0].S.F = 0;
a[0].S.S = 0;
sort(a + 1, a + n + 1);
a[n + 1].F = len;
a[n + 1].S.F = 0;
a[n + 1].S.S = 0;
if(n == 1){
if(a[1].F <= a[1].S.S and (a[1].F + len - a[1].F - a[1].S.F <= a[1].S.S))
cout << min(len, a[1].F + max(0ll, len - a[1].F - a[1].S.F)) << '\n';
else cout << len << '\n';
return;
}
}
int main() {
fast;
int t = 1;
// cin >> t;
while(t--)
solve();
return 0;
}
# | 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... |