#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define ll long long
using namespace std;
namespace __gnu_pbds
{
typedef tree<ll,
null_type,
less_equal<ll>,
rb_tree_tag,
tree_order_statistics_node_update> ordered_set;
}
using namespace __gnu_pbds;
#define fi ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//#define ll double
#define ll1 long long
#define F first
#define S second
#define sz size()
#define all(s) s.begin(),s.end()
#define all1(s) s.rbegin(),s.rend()
ll mod=1e9+7;
int main()
{
fi
//freopen("stdin.in","r",stdin);freopen("stdout.out","w",stdout);
//cin>>T;ll oo=0;
ll n,k;
cin>>n>>k;
pair<ll,pair<ll,ll>>a[n];
for(ll i=0;i<n;i++){
cin>>a[i].F>>a[i].S.F>>a[i].S.S;
}
sort(a,a+n);
ll l=0,r=1e9;ll ans;
while(l<=r){
ll mid=(l+r)/2;ll o=mid;ll p=0;ll u=0;
for(ll i=0;i<n;i++){
if(a[i].S.F>=mid){
o+=a[i].S.S-(a[i].F-u);u=a[i].F;
}
}
if(o-(k-u)>=0){
ans=mid;r=mid-1;
}else l=mid+1;
}cout<<ans;
}
Compilation message
FuelStation.cpp: In function 'int main()':
FuelStation.cpp:39:36: warning: unused variable 'p' [-Wunused-variable]
39 | ll mid=(l+r)/2;ll o=mid;ll p=0;ll u=0;
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
105 ms |
15908 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Incorrect |
3 ms |
732 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Incorrect |
3 ms |
732 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |