记录编号 |
240002 |
评测结果 |
AAAAAAAAAA |
题目名称 |
[HAOI 2010]工厂选址 |
最终得分 |
100 |
用户昵称 |
Fmuckss |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.692 s |
提交时间 |
2016-03-21 10:50:22 |
内存使用 |
0.86 MiB |
显示代码纯文本
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#include<algorithm>
using namespace std;
typedef long long LL;
const int maxn = 52;
const int maxm = 50005;
const LL inf = 1e17;
int n, m, s, t, b, h;
int a[maxm];
int cos[maxm];
LL tot;
int hs[maxn];
LL sum;
int get_num() {
char tmp;
int ans = 0;
tmp = getchar();
while(tmp > '9' || tmp < '0') tmp = getchar();
while(tmp <= '9' && tmp >= '0') {
ans = ans*10 + tmp - '0';
tmp = getchar();
}
return ans;
}
struct node {
int c, tar;
bool operator < (const node b) const{
return c < b.c;
}
}ns[maxm];
void 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];
}
for(int i = 1; i <= n; i++) {
hs[i] = get_num();
}
for(int i = 1; i <= m; i++) {
cos[i] = get_num();
tot += cos[i]*a[i];
}
}
void solve() {
LL nowtar, nowmin = inf, now, le;
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= m; j++) {
ns[j].tar = j;
ns[j].c = get_num() - cos[j];
}
sort(ns+1, ns+1+m);
now = tot, le = sum-b;
for(int j = 1; j <= m ;j++) {
if(le > a[ns[j].tar]) {
le -= a[ns[j].tar];
now += a[ns[j].tar]*ns[j].c;
} else {
now += le*ns[j].c;
break;
}
}
if(now+hs[i] < nowmin) {
nowmin = now+hs[i];
nowtar = i;
}
}
printf("%lld\n%lld", nowtar, nowmin+h);
}
int main() {
freopen("factory1.in", "r", stdin);
freopen("factory1.out", "w", stdout);
read();
solve();
return 0;
}