Submission #750374

#TimeUsernameProblemLanguageResultExecution timeMemory
750374pccSemiexpress (JOI17_semiexpress)C++14
100 / 100
1 ms340 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define tlll tuple<ll,ll,ll> #define mk(a,b,c) make_tuple(a,b,c) ll n,m,k,a,b,c,T; int main(){ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin>>n>>m>>k>>a>>b>>c>>T; priority_queue<tlll,vector<tlll>,less<tlll>> pq; ll arr[m]; k -= m; for(auto &i:arr)cin>>i; ll ans = 0; for(int i = 0;i<m-1;i++){ if(b*(arr[i]-1)>T)break; ll ta = (T-b*(arr[i]-1))/a; ta = min(ta,arr[i+1]-arr[i]-1); if(i != 0)ans += ta+1; else ans += ta; ll dx = arr[i]+ta+1; if(dx>=arr[i+1])continue; if(T-b*(arr[i]-1)-c*(dx-arr[i])<0)continue; ll dxx = dx+(T-b*(arr[i]-1)-c*(dx-arr[i]))/a; dxx = min(dxx,arr[i+1]-1); pq.push(mk(dxx-dx+1,dx,i)); //cout<<i<<":"<<ta<<','<<dx<<','<<dxx<<','<<arr[i]<<endl; } if(b*(n-1)<=T)ans++; //cout<<ans<<endl;return 0; while(k>0&&!pq.empty()){ k--; if(get<0>(pq.top())<0)break; ans += get<0>(pq.top()); auto np = get<1>(pq.top()); auto fast = get<2>(pq.top()); ll dx = get<0>(pq.top())+np; pq.pop(); ll dxx = dx+(T-b*(arr[fast]-1)-c*(dx-arr[fast]))/a; dxx = min(dxx,arr[fast+1]-1); //cout<<arr[fast]<<' '<<np<<' '<<dx<<' '<<dxx<<endl; if(dx>=arr[fast+1])continue; if(T-b*(arr[fast]-1)-c*(dx-arr[fast])<0)continue; pq.push(mk(dxx-dx+1,dx,fast)); } cout<<ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...