训练联盟补题

A Architecture
Your brother has won an award at the recent Breakthroughs in Architectural Problems Con-
ference and has been given the once in a lifetime opportunity of redesigning the city center
of his favorite city Nijmegen. Since the most striking parts of a city’s layout are the skylines,
your brother has started by drawing ideas for how he wants the northern and eastern skylines
of Nijmegen to look. However, some of his proposals look rather outlandish, and you are
starting to wonder whether his designs are possible.
For his design, your brother has put an R × C grid on the city. Each cell of the city will
contain a building of a certain height. The eastern skyline is given by the tallest building in
each of the R rows, and the northern skyline is given by the tallest building in each of the C
columns.
A pair of your brother’s drawings of skylines is possible if and only if there exists some way
of assigning building heights to the grid cells such that the resulting skylines match these
drawings.
Figure A.1 shows a possible city with the northern and eastern skylines exactly as given in
the input of the first sample.
1 2 3 4
0 1 2 3
1 2 1 1
1 0 1 1
Figure A.1: Example city showing sample 1 has a valid solution.
Input
• The first line consists of two integers 1 ≤ R,C ≤ 100, the number of rows and columns
in the grid.
• The second line consists of R integers x 1 ,…,x R describing the eastern skyline (0 ≤ x i ≤ 1000
for all i).
• The third line consists of C integers y 1 ,…,y C describing the northern skyline (0 ≤ y j ≤ 1000
for all j).
Output
Output one line containing the string possible if there exists a city design that produces
the specified skyline, and impossible otherwise.
Sample Input 1 Sample Output 1
4 4
4 3 2 1
1 2 3 4
possible
4 Problem A: Architecture
Sample Input 2 Sample Output 2
4 4
1 2 3 4
1 2 3 2

#include<cstdio>
#include<algorithm>
#include<iostream>
#include<string.h>
#include<vector>
#include<set>
#include<cmath>
#include<map>
using namespace std;
#define maxn 105
#define ll long long
#define mod 1000000007
int n, m;
int a[105], b[105];
int main()
{
	scanf("%d %d", &n, &m);
	int mxl = -1, mxr = -1;
	for (int i = 1; i <= n; i++) scanf("%d", &a[i]), mxl = max(mxl, a[i]);
	for (int i = 1; i <= m; i++) scanf("%d", &b[i]), mxr = max(mxr, b[i]);
	if(mxl == mxr) printf("possible\n");
	else printf("impossible\n");
	return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值