Submission #958036

#TimeUsernameProblemLanguageResultExecution timeMemory
958036Zena_HossamFuel Station (NOI20_fuelstation)C++14
0 / 100
105 ms15908 KiB
#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 (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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...