#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN=3e4+5;
priority_queue<tuple<ll, ll, ll> > pq;
int n, m, k;
ll x, y, z, q;
ll v[MAXN], custo[MAXN];
int respf;
int main() {
scanf("%d %d %d", &n, &m, &k);
scanf("%lld %lld %lld", &x, &y, &z);
scanf("%lld", &q);
for(int i=1; i<=m; i++) {
scanf("%lld", &v[i]);
custo[i]=(v[i]-1)*y;
if(custo[i]<=q) respf++;
if(i!=1) {
if(custo[i-1]>q) continue;
ll posso=(q-custo[i-1])/x;
ll sobrou=v[i]-v[i-1]-1;
posso=min(posso, sobrou);
ll fcusto=custo[i-1]+z*(posso+1);
ll fposso=(q-fcusto)/x+1;
fposso=min(fposso, sobrou-posso);
//printf("%d:: %lld %lld // (%lld %lld %lld) -- respf %d\n", i, posso, sobrou, fposso, fcusto, sobrou-posso, respf);
respf+=posso;
if(fposso>0&&fcusto<=q) pq.push({fposso, fcusto, sobrou-posso});
}
}
// printf("tenho %d\n", respf);
// while(pq.size()) printf("(%lld %lld %lld)\n", get<0>(pq.top()), get<1>(pq.top()), get<2>(pq.top())), pq.pop();
k-=m;
while(k--) {
if(pq.empty()) break;
ll fposso, fcusto, fsobrou; tie(fposso, fcusto, fsobrou)=pq.top(); pq.pop();
respf+=fposso;
fsobrou-=fposso;
fcusto+=fposso*z;
fposso=(q-fcusto)/x;
fposso=min(fposso, fsobrou);
//printf("add %lld %lld %lld\n", fposso, fcusto, fsobrou);
if(fposso>0) pq.push({fposso, fcusto, fsobrou});
}
printf("%d\n", respf-1);
}
Compilation message
semiexpress.cpp: In function 'int main()':
semiexpress.cpp:13:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d %d", &n, &m, &k);
~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
semiexpress.cpp:14:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld %lld %lld", &x, &y, &z);
~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
semiexpress.cpp:15:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld", &q);
~~~~~^~~~~~~~~~~~
semiexpress.cpp:17:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld", &v[i]);
~~~~~^~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |