【HDU】6047
来源:互联网 发布:网红张大奕的淘宝店 编辑:程序博客网 时间:2024/05/17 04:18
题目链接:点击打开题目
跟队友商量了一下,感觉前面的数越大,结果就越优,那么我们就把b排一下序,然后跑一遍就行啦。
代码如下:
#include<cstdio>#include<vector>#include<algorithm>using namespace std;#define INF 0x3f3f3f3fint a[250000+5];int maxx[250000+5];vector<int> b;const int MOD = 1e9 + 7;int main(){ int n; int ans; while (~scanf ("%d",&n)) { ans = 0; for (int i = 1 ; i <= n ; i++) scanf ("%d",&a[i]); b.clear(); b.resize(n); for (int i = 0 ; i < n ; i++) scanf ("%d",&b[i]); maxx[n] = a[n]-n; for (int i = n-1 ; i >= 1 ; i--) maxx[i] = max(maxx[i+1],a[i]-i); sort(b.begin(),b.end()); int t = -INF; //后面数的最大值 for (int i = 0 ; i < n ; i++) { int num = max(maxx[b[i]],t); t = max(t,num-(n+i+1)); ans = (ans + num) % MOD; } printf ("%d\n",ans); } return 0;}
阅读全文
0 0
- 【HDU】6047
- hdu 6047
- hdu 6047
- HDU 6047
- HDU 6047
- hdu 6047
- [HDU]-6047 Maximum Sequence
- hdu 6047 Maximum Sequence
- [HDU 6047]Maximum Sequence
- HDU 6047 Maximum Sequence
- hdu 6047 Maximum Sequence
- HDU 6047 Maximum Sequence
- hdu 6047 Maximum Sequence
- HDU 6047 Maximum Sequence
- hdu--6047--Maximum Sequence
- hdu 6047 Maximum Sequence
- HDU 6047 Maximum Sequence
- hdu 6047 Maximum Sequence
- 模板设置(java代码)
- Freeline框架解析
- 打印出给定字符串中字符的所有不重复排列
- HDU1215七夕节
- 刷题报告003 洛谷P1011 车站
- 【HDU】6047
- 大话设计模式-Study-Tips-第一章-简单工厂模式
- 设计思维分享
- 【深度学习】图像标注评价标准
- ++ map、multimap 的使用方法
- redhat 7安装CentOS 7 yum源
- 设计模式分类
- PAT 甲级 1010.Radix (25)
- 190. Reverse Bits