不想说什么了。。。一眼题,排个序贪心。。。
样例过不了,怎么可能?!
乱搞搞了一个小时,终于搞定样例了
发现是题目描述的问题:原来的发电站必须只收b吨!!!!!您倒是说说清楚啊我去。。。
网上过的那些人都是一A的?不敢相信。。。
1 /************************************************************** 2 Problem: 2426 3 User: rausen 4 Language: C++ 5 Result: Accepted 6 Time:332 ms 7 Memory:1592 kb 8 ****************************************************************/ 9 10 #include <cstdio> 11 #include <algorithm> 12 using namespace std; 13 const int N = 55; 14 const int M = 50005; 15 struct data{ 16 int del, cnt; 17 data(void){} 18 data(int a, int b) : del(a), cnt(b) {} 19 }c[M]; 20 inline bool operator < (const data a, const data b){ 21 return a.del > b.del; 22 } 23 24 inline int read(){ 25 int x = 0, sgn = 1; 26 char ch = getchar(); 27 while (ch < '0' || ch > '9'){ 28 if (ch == '-') sgn = -1; 29 ch = getchar(); 30 } 31 while (ch >= '0' && ch <= '9'){ 32 x = x * 10 + ch - '0'; 33 ch = getchar(); 34 } 35 return sgn * x; 36 } 37 38 int m, n, b, H; 39 int sum_a, sum_cost; 40 int a[M], h[N], C[M]; 41 42 int main(){ 43 m = read(), b = read(), H = read(), n = read(); 44 for (int i = 1; i <= m; ++i) 45 a[i] = read(), sum_a += a[i]; 46 sum_a -= b; 47 for (int i = 1; i <= n; ++i) 48 h[i] = read(); 49 for (int i = 1; i <= m; ++i) 50 C[i] = read(), sum_cost += C[i] * a[i]; 51 52 int sum, j, rest, ans = (int) 1e9, ans1; 53 for (int i = 1; i <= n; ++i){ 54 sum = sum_cost, rest = sum_a; 55 for (j = 1; j <= m; ++j) 56 c[j] = data(C[j] - read(), a[j]); 57 sort(c + 1, c + m + 1); 58 59 for (j = 1; j <= m; ++j) 60 if (rest >= c[j].cnt) 61 rest -= c[j].cnt, sum -= c[j].cnt * c[j].del; 62 else break; 63 if (rest > 0) 64 sum -= rest * c[j].del; 65 if (ans > sum + h[i]) 66 ans1 = i, ans = sum + h[i]; 67 } 68 printf("%d\n%d\n", ans1, ans + H); 69 return 0; 70 }
By Xs酱~ 转载请说明
博客地址:http://www.cnblogs.com/rausen