Submission #365040

# Submission time Handle Problem Language Result Execution time Memory
365040 2021-02-10T20:00:32 Z nafis_shifat Semiexpress (JOI17_semiexpress) C++14
100 / 100
9 ms 4572 KB
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
using namespace std;
const int mxn=1e5+5;
const int inf=1e9;
priority_queue<ll> pq;
ll a,b,c;
ll n,m,k;
ll t;
ll res = 0;
void prc(ll l,ll r) {
	ll cost = (l - 1) * b;

	if(cost > t) return;

	ll td = (t - cost)/a;
	ll i = min(r,l + td + 1);
	res += i - l;
	int cnt = 0;
	while(cnt <= k - m && i < r) {
		ll lc = cost + (i - l) * c;
		if(lc > t) return;
		ll x = (t - lc) / a;
		ll to = min(r,i + x + 1);
		pq.push(to - i);
		i = to;
		cnt++;
	}

}
int main() {
	
	cin >> n >> m >> k;
	cin >> a >> b >> c;
	cin>>t;

	ll exp[m + 1];

	for(int i = 1; i <= m; i++) cin >> exp[i];
    
    for(int i = 2; i <= m; i++) prc(exp[i - 1],exp[i]);

    for(int i = 1; i <= k - m && !pq.empty(); i++) {
    	res += pq.top();
    	pq.pop();
    } 

    if(b * (exp[m] - 1) <= t) res++;
    cout<<res - 1<<endl;

	
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 2 ms 620 KB Output is correct
23 Correct 9 ms 4572 KB Output is correct
24 Correct 1 ms 492 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 1 ms 364 KB Output is correct
27 Correct 1 ms 492 KB Output is correct
28 Correct 1 ms 492 KB Output is correct
29 Correct 7 ms 4572 KB Output is correct
30 Correct 4 ms 2528 KB Output is correct