CodeForces
来源:互联网 发布:广发证券炒股软件 编辑:程序博客网 时间:2024/06/05 11:37
题目链接:
http://codeforces.com/problemset/problem/581/B
B - Luxurious Houses CodeForces - 581B
题目大意:
给一个数列 , 如果这个数比右边最大的数还要大, 那么是符合题意的。 现在要每个数加上一个数 ,使这个更新后的数列是符合题意的 。求每个这个数 。
1e5数据 逆序处理
#include <bits/stdc++.h>using namespace std;typedef long long ll;#define mem(s,t) memset(s,t,sizeof(s))#define D(v) cout<<#v<<" "<<v<<endl#define inf 0x3f3f3f3fconst int MAXN =1e5+10;int a[MAXN],ans[MAXN];int main() {#ifdef LOCAL freopen("in.txt","r",stdin); freopen("out.txt","w",stdout);#endif int n; while(~scanf("%d",&n)) { mem(a,0); mem(ans,0); for(int i=0; i<n; i++) { scanf("%d",a+i); } int maxn=0; for(int i=n-1; i>=0; i--) { if(i==n-1) { ans[i]=0; maxn=max(maxn,a[i]); continue; } if(maxn==a[i]) { ans[i]=1; } else if(a[i]>maxn) { ans[i]=0; maxn=a[i]; } else { ans[i]=maxn-a[i]+1; } } for(int i=0; i<n; i++) { if(i) printf(" %d",ans[i]); else printf("%d",ans[i]); } puts(""); }}
ps.五月份竟然要过去了,回想起来也没做什么事情,前半个月忙于省赛,后面半个月,想起来只有两件事,自己的生日和整个小组连着通宵 3 天赶创新实践结题。生日那天,原本计划了很多,但是最近越来越没心情,干脆就叫了几个朋友撸串。最近心态改变了很多吧,内心颇不平静。至于项目,暑假还要接着干,这个课程在后天 6.2 报告,期末真的事情超级多。
跑题了,忙里偷闲水一了一题。
阅读全文
0 0
- codeforces~~~
- Codeforces
- codeforces
- Codeforces
- codeforces
- codeforces
- Codeforces
- Codeforces
- CodeForces
- CodeForces
- CodeForces
- CodeForces
- CodeForces
- Codeforces
- Codeforces
- Codeforces
- Codeforces
- Codeforces
- 制作多周期CPU(分析)
- display
- web前端之12种不宜使用的Javascript语法
- Spring框架基本概念,Spring框架模块详解
- LeetCode 376. Wiggle Subsequence
- CodeForces
- Java原码、反码和补码的算法,Java跨平台原理,以及JDK安装目录说明
- DLib中调用人脸对齐+VS2013
- 南阳理工26题孪生素数
- sass基本使用
- 使用Gulp + Webpack定制前端开发环境
- pat-a 1094. The Largest Generation (25)
- Kotlin编程之扩展属性和扩展伴生对象
- 分享一个第三方ViewPager库