【反序表+树状数组】Codeforces Round #441(Div.2)D[Sorting the Coins]题解
来源:互联网 发布:淘宝冷光美白仪有用么 编辑:程序博客网 时间:2024/05/21 09:55
题目概述
刚开始有一个全是
解题报告
这道题明显是个伪反序表(不是排列),但是可以沿用反序表的性质:冒泡的次数
由于只有
所以每次维护最后一个
示例程序
#include<cstdio>using namespace std;const int maxn=300000;int n,lst,p[maxn+5],c[maxn+5];inline void Update(int x,int tem) {for (int i=x;i<=n;i+=i&-i) c[i]+=tem;}inline int Sum(int x) {int sum=0;for (int i=x;i;i-=i&-i) sum+=c[i];return sum;}int main(){ scanf("%d",&n);lst=n;printf("1"); for (int i=1,x;i<n;i++) { scanf("%d",&x);Update(x,1);p[x]=1;while (p[lst]) lst--; printf(" %d",Sum(lst-1)+1); } return printf(" 1\n"),0;}
阅读全文
0 0
- 【反序表+树状数组】Codeforces Round #441(Div.2)D[Sorting the Coins]题解
- Codeforces Round #441 D. Sorting the Coins
- Codeforces Round #441 D. Sorting the Coins
- Codeforces Round #441 (Div. 2, by Moscow Team Olympiad) D. Sorting the Coins 乱搞
- Codeforces Round #441 (Div. 2, by Moscow Team Olympiad) D. Sorting the Coins
- Codeforces Round #441 (Div. 2, by Moscow Team Olympiad) D. Sorting the Coins【规律】
- [冒泡 反序表] Codeforces #876D. Sorting the Coins
- Codeforces Round #441 D. Sorting the Coins(线段树)
- Codeforces Round #424 (Div. 2) E. Cards Sorting(树状数组)
- Codeforces Round #424 (Div. 2)C. Jury Marks 暴力 D. Office Keys 二分 E. Cards Sorting 树状数组
- Codeforces Round #261 (Div. 2) D 树状数组应用
- 树状数组Codeforces Round #261 (Div. 2)D
- Codeforces Round #220 (Div. 2) D 树状数组 && 二分
- Codeforces 875B Sorting the Coins 题解
- Codeforces 875B (Round 441 D1) Sorting the Coins
- #440 Div.2 D.Sorting the Coins 硬币排序问题
- CodeForces 876D Sorting the Coins
- Codeforces 876 D. Sorting the Coins 模拟
- Generic Views
- mysql使用like查询使用
- JavaEE上传和下载
- 51nod-1140-矩阵相乘结果的判断
- CAD批量转pdf的教程
- 【反序表+树状数组】Codeforces Round #441(Div.2)D[Sorting the Coins]题解
- 深度学习人工智能/大数据/云计算-书籍整理
- 添加路由
- Python 递归
- webstorm快捷键大全(亲自整理)
- ProtoBuffer消息设计经验
- 风险管理方法论和选择审计方法
- Sublime text3常用插件
- 用AVCodecParameters代替AVCodecContext