이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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);
respf+=posso;
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);
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+1;
fposso=min(fposso, fsobrou);
// printf("add %lld %lld %lld\n", fposso, fcusto, fsobrou);
if(fposso>0&&fcusto<=q) pq.push({fposso, fcusto, fsobrou});
}
printf("%d\n", respf-1);
}
컴파일 시 표준 에러 (stderr) 메시지
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]);
~~~~~^~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |