UVA-1445 Cubist Artwork

Source: Internet
Author: User

The main topic: give an irregular graph of the front and left view, ask how many small cubes to use.

Thinking: It's easy to think that if the front and left views have a column that is exactly the same height, you can omit one column.

#include <cstdio>#include <algorithm>using namespace STD;intMain () {intW, D; while(scanf("%d%d", &w, &d) && W + d) {intH, f[ -] = {0}, s[ -] = {0}; for(inti =0; i < W; i++) {scanf("%d", &h);        f[h]++; } for(inti =0; I < D; i++) {scanf("%d", &h);        s[h]++; }intAns =0; for(inti =1; I <= -; i++) ans + = max (F[i], s[i]) * i;printf("%d\n", ans); }return 0;}

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

UVA-1445 Cubist Artwork

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.