이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
컴파일 시 표준 에러 (stderr) 메시지
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;
| ^
# | 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... |