Question:
A graph composed of several cubes provides its positive and lateral views, and calculates the minimum number of cubes that meet the conditions.
Analysis:
Although it is a simple greedy, there is no good idea.
Once again, I looked at others' questions with shame.
Http://blog.csdn.net/u011345461/article/details/38491661
1 #include <cstdio> 2 #include <cstring> 3 #include <algorithm> 4 5 const int maxn = 25; 6 int a[maxn], b[maxn]; 7 8 int main(void) 9 {10 //freopen("4636in.txt", "r", stdin);11 int m, n;12 while(scanf("%d%d", &m, &n) == 2 && m && n)13 {14 memset(a, 0, sizeof(a));15 memset(b, 0, sizeof(b));16 int x;17 for(int i = 0; i < m; ++i) { scanf("%d", &x); a[x]++; }18 for(int i = 0; i < n; ++i) { scanf("%d", &x); b[x]++; }19 20 int ans = 0;21 for(int i = 0; i < maxn; ++i)22 ans += i * std::max(a[i], b[i]);23 24 printf("%d\n", ans);25 }26 27 return 0;28 }
Code Jun
La 4636 (Greedy) cubist artwok