URAL
来源:互联网 发布:ubuntu 新建文档 编辑:程序博客网 时间:2024/06/10 20:49
#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>using namespace std;const int maxn = 1e5 + 10;int n, k, a[maxn], ans[maxn], res;struct Tree { int data[maxn<<1]; void init() { memset(data, 0, sizeof(data)); } void pushup(int root) { data[root] = data[root<<1] + data[root<<1|1]; } void updata(int l, int r, int root, int pos) { if (l == r) { data[root] += 1; return; } int mid = (l + r)>>1; if (pos <= mid) updata(l, mid, root<<1, pos); else updata(mid + 1, r, root<<1|1, pos); pushup(root); } int query(int l, int r, int root, int ql, int qr) { if (ql <= l && r <= qr) { return data[root]; } int mid = (l + r)>>1; int ans = 0; if (ql <= mid) ans += query(l, mid, root<<1, ql, qr); if (mid < qr) ans += query(mid + 1, r, root<<1|1, ql, qr); return ans; }}tree;int main() { while (~scanf("%d %d", &n, &k)) { res = 0; for (int i = 1; i <= k; i++) { for (int j = 1; j <= n; j++) scanf("%d", &a[j]); tree.init(); int sum = 0; for (int j = n; j >= 1; j--) { sum += tree.query(1, n, 1, 1, a[j]); tree.updata(1, n, 1, a[j]); } ans[i] = sum; res = max(res, sum); } for (int i = 1; i <= k; i++) { if (ans[i] == res) { printf("%d\n", i); break; } } } return 0;}
阅读全文
0 0
- URAL
- 【ural】
- URAL
- URAL
- URAL
- URAL
- URAL
- URAL
- URAL
- URAL
- URAL
- URAL
- URAL
- URAL
- URAL
- URAL
- URAL
- URAL
- python 两个数列和的最小差值
- Linux ftp服务
- js显示默认图片
- linux top 命令参数详解
- css 宽度与高度按百分比显示,且宽高相等,span高度百分比
- URAL
- 分布式事务
- Hadoop和大数据:60款顶级开源工具
- CVX介绍——半定规划模式
- 动态规划总结
- Context initialization failed org.springframework.beans.factory.UnsatisfiedDependencyException: Erro
- NIPS 2017 | 线上分享第一期:似自然梯度的优化算法KFAC与强化学习算法ACKTR
- 【Android开发遇错】Eslipce迁移Android studo项目报错: com.intellij.openapi.project.IndexNotReadyException:
- 基于对偶学习的跨领域图片描述生成