【贪心】17.6.1 优雅的序列 题解
来源:互联网 发布:数控机床编程技术 编辑:程序博客网 时间:2024/06/10 00:34
取每一次的lis就可以了
#include <iostream>#include <cstdio>#include <algorithm>using namespace std;const int maxn = 1e5+5;int n,tot,ans;int a[maxn],b[maxn];template <class T> inline void read(T &x) { int flag = 1; x = 0; char ch = getchar(); while(ch < '0' || ch > '9') { if(ch == '-') flag = -1; ch = getchar(); } while(ch >= '0' && ch <= '9') { x = (x<<1)+(x<<3)+ch-'0'; ch = getchar(); } x *= flag;}int main() { freopen("grace.in","r",stdin); freopen("grace.out","w",stdout); read(n); for(int i = 1; i <= n; i++) read(a[i]); sort(a+1, a+1+n); for(int i = 1; i <= n; i++) if(a[i] == a[i-1]) b[tot]++; else b[++tot]++; sort(b+1, b+1+tot); for(int i = 1; i <= tot; i++) if(b[i] != b[i-1]) ans += (tot-i)*(b[i]-b[i-1]); printf("%d\n",ans); return 0;}
阅读全文
0 0
- 【贪心】17.6.1 优雅的序列 题解
- 【贪心】17.6.1 漂流 题解
- 经典题目:优雅的序列
- 【贪心】51Nod1241[特殊的排序]题解
- 【贪心】51Nod1615[跳跃的杰克]题解
- [JSOI2007] 奶酪 题解 贪心 O(1)
- pongo题解之子序列的个数
- 栈的压入、弹出序列题解
- sequence题解(贪心)
- 贪心:HDU - 2037 题解
- 贪心 HDU 2037题解
- HDU贪心题解
- 序列(rms模拟7-1)* *(贪心)
- 【BZOJ】【P1907】【树的路径覆盖】【题解】【贪心】
- 题解BZOJ 2563 阿狸和桃子的游戏 [贪心]
- 【贪心+ST算法+堆】BZOJ4458[GTY的OJ]题解
- Codevs3657括号序列题解
- 【题解】dutoj1081 Prufer 序列
- Android客户端与服务器交互方式(1)
- xamarin学习笔记A04(安卓基本布局)
- Java实现流控-Semaphore
- phpstorm用laravel开发
- 理解typename的两个含义
- 【贪心】17.6.1 优雅的序列 题解
- 实现静态顺序表和动态顺序表
- github提交代码避免输入用户名和密码的方法总结
- 此贴用于记录各种碎片知识
- 2017年第0届浙江工业大学之江学院程序设计竞赛决赛—J qwb又偷懒了
- cookies,sessionStorage和localStorage的区别
- 搜索系统开发
- cocos2dx入门需要了解的工具
- Android开发中常见的10个错误