Submission #750374

# Submission time Handle Problem Language Result Execution time Memory
750374 2023-05-29T12:47:15 Z pcc Semiexpress (JOI17_semiexpress) C++14
100 / 100
1 ms 340 KB
#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 time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 320 KB Output is correct