답안 #123598

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
123598 2019-07-01T17:59:06 Z wilwxk Semiexpress (JOI17_semiexpress) C++11
0 / 100
2 ms 256 KB
#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 -- respf %d\n", i, posso, sobrou, fcusto, fposso, respf);
			respf+=posso;
			if(fposso>0) 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();

	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 252 KB Output is correct
2 Incorrect 2 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 252 KB Output is correct
2 Incorrect 2 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 252 KB Output is correct
2 Incorrect 2 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -