记录编号 |
390292 |
评测结果 |
AAAAAAAAAA |
题目名称 |
[HAOI 2010]工厂选址 |
最终得分 |
100 |
用户昵称 |
kZime |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.351 s |
提交时间 |
2017-04-02 16:46:33 |
内存使用 |
1.27 MiB |
显示代码纯文本
- ;/*kZime*/
- #include <iostream>
- #include <cstdio>
- #include <cstring>
- #include <cmath>
- #include <vector>
- #include <queue>
- #include <stack>
- #include <cstdlib>
- #include <algorithm>
- #define MAXN 50005
- using namespace std;
- /*-----------------------------------------------------------------------------*/
- inline void File_Read() {
- #ifndef MYLAB
- freopen("factory1.in", "r", stdin);
- freopen("factory1.out", "w", stdout);
- #else
- // freopen("in.txt", "r", stdin);
- #endif
- }
-
- inline int get_num() {
- int k = 0, f = 1; char c = getchar();
- for(; !isdigit(c); c = getchar())if(c == '-') f = -1;
- for(; isdigit(c); c = getchar()) k = k * 10 + c - '0';
- return k * f;
- }
-
- struct fire_energy {
- int c, tar;
- }f[MAXN];
-
- bool cmp(fire_energy a, fire_energy b) {
- return a.c < b.c;
- }
-
- int n, b, h, m;
- int cost[MAXN], hi[MAXN], a[MAXN];
- int sum, tot, pos;
-
- int main() {
- File_Read();
- m = get_num();
- b = get_num();
- h = get_num();
- n = get_num();
- for(int i = 1; i <= m; i++) {
- a[i] = get_num();
- sum += a[i]; // sum代表的是总产煤
- }
- for(int i = 1; i <= n; i++) {
- hi[i] = get_num();
- }
- for(int i = 1; i <= m; i++) {
- cost[i] = get_num();
- tot += cost[i] * a[i]; // tot是指原厂运煤的总成本
- }
- long long ans = 0x7fffffff, now , le;
- for(int i = 1; i <= n; i++) {
- for(int j = 1; j <= m; j++) {
- f[j].c = get_num() - cost[j];
- f[j].tar = j;
- }
- sort(f + 1, f + 1 + m, cmp);
- now = tot, le = sum - b;//now为当前最小成本
- //le是剩余可判断的煤量
- for(int j = 1; j <= m; j++) {
- if(le > a[f[j].tar]) {
- le -= a[f[j].tar];
- now += f[j].c * a[f[j].tar];
- } else {
- now += le * f[j].c;
- break;
- }
- }
- if(now + hi[i] < ans) {
- ans = now + hi[i];
- pos = i;
- }
- }
-
- printf("%d\n%lld\n", pos, ans + h);
-
- return 0;
- }
-