当前位置: 首页 > news >正文

深圳企业专业网站设计/广州网站定制多少钱

深圳企业专业网站设计,广州网站定制多少钱,wordpress网页图标,东莞响应式网站哪里好http://acm.hdu.edu.cn/showproblem.php?pid2227 用dp[i]表示以第i个数为结尾的nondecreasing串有多少个。 那么对于每个a[i] 要去找 < a[i]的数字那些位置&#xff0c;加上他们的dp值即可。 可以用树状数组维护 #include <cstdio> #include <cstdlib> #includ…

http://acm.hdu.edu.cn/showproblem.php?pid=2227

 

用dp[i]表示以第i个数为结尾的nondecreasing串有多少个。

那么对于每个a[i]

要去找 <= a[i]的数字那些位置,加上他们的dp值即可。

可以用树状数组维护

 

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <assert.h>
#define IOS ios::sync_with_stdio(false)
using namespace std;
#define inf (0x3f3f3f3f)
typedef long long int LL;#include <iostream>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
const int MOD = 1000000007;
const int maxn = 100000 + 20;
LL a[maxn], b[maxn];
int n;
LL c[maxn];
LL lowbit(LL x) {return x & (-x);
}
void UpDate(int pos, LL val) {while (pos <= n) {c[pos] += val;if (c[pos] >= MOD) c[pos] %= MOD;pos += lowbit(pos);}
}
LL query(int pos) {LL ans = 0;assert(pos >= 0);while (pos) {ans += c[pos];pos -= lowbit(pos);}return ans;
}
void work() {memset(c, 0, sizeof c);for (int i = 1; i <= n; ++i) {cin >> a[i];b[i] = a[i];}sort(b + 1, b + 1 + n);LL ans = 0;for (int i = 1; i <= n; ++i) {int pos = lower_bound(b + 1, b + 1 + n, a[i]) - b;LL tans = query(pos) + 1;ans += tans;if (ans >= MOD) ans %= MOD;UpDate(pos, tans);}cout << ans << endl;
}int main() {
#ifdef localfreopen("data.txt", "r", stdin);
//    freopen("data.txt", "w", stdout);
#endifIOS;while (cin >> n) work();return 0;
}
View Code

 

转载于:https://www.cnblogs.com/liuweimingcprogram/p/6143541.html

http://www.jmfq.cn/news/4946779.html

相关文章:

  • 地产平面网站/热门seo推广排名稳定
  • 做论坛网站多少钱/电子商务网站建设流程
  • 潍坊市建设一体化平台网站/淘宝指数网站
  • 云南建设厅网站执业注册/淘特app推广代理
  • 手机网站建设请示/发稿媒体平台
  • 网站开发设计思想/网页设计制作网站
  • 保险咨询网站留电话/友情链接怎么连
  • wordpress 会员登录可见/湖南优化公司
  • 微信开发网站开发未来前景/seo的目的是什么
  • 南海专业网站建设公司/计算机培训
  • 网站建设南宁/兰州怎么提高网站的排名
  • 网站域名多少钱一年/广告推广一个月多少钱
  • php+mysql+dreamweaver网站建设典型案例/新闻发布
  • 做网站对程序员说那些需求/什么是搜索引擎优化
  • 陕西网渭南站/个人网站推广平台大全
  • 广州做网站lomuw/公司建设网站哪家好
  • 大气政府网站模板/html简单网页设计作品
  • 长沙制作网站公司吗/广告营销策略
  • 中英网站怎么做/淘宝网店怎么运营起来
  • 网站网页设计制作教程/软件开发公司经营范围
  • 天津外贸公司网站制作/seo网站怎么搭建
  • 建什么网站能百度收录/app如何推广
  • 网站是别人做的我这就没有根目录/推广工具
  • 贵州省住房和城乡建设厅查询网站首页/seo经理招聘
  • 宜昌网站建设兼职/网店如何推广
  • 南京网站制作公司哪家靠谱/沪深300指数基金
  • 自己做的视频网站如何赚钱/查询网站流量的网址
  • 触屏版网站模板/朋友圈推广文案
  • 网站建设质量保证/优化网站排名技巧
  • 印刷报价网站源码下载/微信怎么做推广