n个房子在一列上,每个房子有高度值
定义: 如果房子i的高度比右边所有房子都高,则 为 高贵的房子
求出对每一个房子,要使得自己变成高贵的房子需要增加多少高度
直接预处理右边所有房子高度最大值即可。
最后输出比较是 右边所有房子的max_high大 还是自己大就可以了
水题
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55#include <cstdio> #include <cmath> #include <cstring> #include <string> #include <algorithm> #include <iostream> #include <queue> #include <map> #include <set> #include <vector> using namespace std; __int64 min(__int64 a,__int64 b) { return a<b?a:b; } __int64 max(__int64 a,__int64 b) { return a>b?a:b; } __int64 tm[100005]; __int64 need[100005]; int main() { __int64 a,b; __int64 n; scanf("%I64d",&n); __int64 i; for (i=1;i<=n;i++) { scanf("%I64d",&tm[i]); } need[n]=0; for (i=n-1;i>=1;i--) { if (tm[i+1]>need[i+1]) need[i]=tm[i+1]; else need[i]=need[i+1]; } for (i=1;i<=n;i++) { if (i!=1) printf (" "); if (tm[i]>need[i]) printf("0"); else printf("%I64d",need[i]-tm[i]+1); } printf("n");
最后
以上就是小巧菠萝最近收集整理的关于CF#322-B. Luxurious Houses-模拟水题的全部内容,更多相关CF#322-B.内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复