[luogu1627 CQOI2009] 中位数 (乱搞)
Solution
好水的题(ーー;)
Code
//By Menteur_Hxy
#include <map>
#include <queue>
#include <cmath>
#include <cstdio>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define Re register
#define Ms(a,b) memset(a,(b),sizeof(a))
#define Fo(i,a,b) for(Re int i=(a),_=(b);i<=_;i++)
#define Ro(i,a,b) for(Re int i=(b),_=(a);i>=_;i--)
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
inline LL read() {
LL x=0,f=1;char c=getchar();
while(!isdigit(c)) {if(c=='-')f=-f;c=getchar();}
while(isdigit(c)) x=(x<<1)+(x<<3)+c-48,c=getchar();
return x*f;
}
const int N=1e5+10;
int n,b,st,sum,ans;
int da[N],t1[N];
map <int,int> M;
int get(int x) {
if(x>b) return 1;
if(x==b) return 0;
if(x<b) return -1;
}
int main() {
n=read(),b=read();
Fo(i,1,n) {da[i]=read();if(da[i]==b) st=i;}
Ro(i,1,st) sum+=get(da[i]),M[sum]++;//,cout<<sum<<" ";cout<<endl;
sum=0;
Fo(i,st,n) sum+=get(da[i]),ans+=M[-sum];//,cout<<sum<<" ";cout<<endl;
printf("%d",ans);
return 0;
}
[luogu1627 CQOI2009] 中位数 (乱搞)的更多相关文章
- Luogu1627 [CQOI2009]中位数
Luogu1627 [CQOI2009]中位数 给出一个 \(n\) 的排列,统计该排列有多少个长度为奇数的连续子序列的中位数是 \(k\) \(n\leq10^5\) \(trick\) :因为不需 ...
- 【BZOJ-3293&1465&1045】分金币&糖果传递×2 中位数 + 乱搞
3293: [Cqoi2011]分金币 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 854 Solved: 476[Submit][Status] ...
- BZOJ1303 [CQOI2009]中位数图 【乱搞】
1303: [CQOI2009]中位数图 Time Limit: 1 Sec Memory Limit: 162 MB Submit: 3086 Solved: 1898 [Submit][Sta ...
- BZOJ1303 [CQOI2009]中位数图
本文版权归ljh2000和博客园共有,欢迎转载,但须保留此声明,并给出原文链接,谢谢合作. 本文作者:ljh2000 作者博客:http://www.cnblogs.com/ljh2000-jump/ ...
- 【NOIP模拟赛】beautiful 乱搞(平衡树)+ST
biubiu~~~ 我用平衡树处理的这道题,然而这种方法还是要看评测姬..... 正解是乱搞....就是枚举每一位数作为中位数,比他小的看做-1比他大的看做1,那么我们从一开始就有了一个绵延的山,我们 ...
- [TJOI2013]奖学金 乱搞
[TJOI2013]奖学金 乱搞 从\(c\)个二元组\((v,w)\)中选出\(n\)个,使其\(v\)的中位数最大的同时使\(w\)和小于等于\(f\),求这个中位数 有点意思.有点像二分答案的思 ...
- URAL 1827 Indigenous Wars(排序、乱搞)
题意:给一个长度为n数组{a[i]}.有m个操作Ti,Si,Li表示找以Ti值结束,以Si值开始,长度为Li的连续子串.找到后,将区间的答案值设为1.一开始答案值全部为0.最后输出n个答案值. 好久没 ...
- BZOJ 1303 CQOI2009 中位数图 水题
1303: [CQOI2009]中位数图 Time Limit: 1 Sec Memory Limit: 162 MBSubmit: 2340 Solved: 1464[Submit][Statu ...
- UVA 11853 [dfs乱搞]
/* 大连热身E题 不要低头,不要放弃,不要气馁,不要慌张 题意: 在1000×1000的格子内有很多个炮弹中心,半径给定. 为某人能否从西部边界出发,从东部边界走出. 不能输出不能,能的话输出最北边 ...
随机推荐
- HDU 4183 Pahom on Water(最大流SAP)
Pahom on Water Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) T ...
- SpringMVC案例2----基于spring2.5的注解实现
和上一篇一样,首先看一下项目结构和jar包 watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvYmVuamFtaW5fd2h4/font/5a6L5L2T/fo ...
- 安装Office Web Apps Server 2013 – KB2592525安装失败
在Windows Server 2008 R2上安装 office web apps Server 的其中一个先决条件是 安装KB2592525. 但由于服务器已经打了SP1及其它大部分的patch, ...
- linux面试之--堆、栈、自由存储区、全局/静态存储区和常量存储区
栈,就是那些由编译器在须要的时候分配,在不须要的时候自己主动清除的变量的存储区.里面的变量一般是局部变量.函数參数等.在一个进程中.位于用户虚拟地址空间顶部的是用户栈,编译器用它来实现函数的调用.和堆 ...
- postgresql数据库psql控制台操作命令
登录postgresql数据库控制台 psql 数据库名 登录成功显示 [zpf@kevin ~]$ psql postgres psql (9.4.1) Type "help" ...
- canvas制作饼图和环形图,使用Excanvas兼容IE67
excanvas 地址:http://excanvas.sourceforge.net/ <!DOCTYPE html> <html> <head> <met ...
- Android中关闭DatePicker、TimePicker、NumberPicker的可编辑模式
DatePicker.TimePicker.NumberPicker这三个控件在使用的过程中,用户点击数字会弹出键盘,有时候会造成布局被挤压不好看,也有其他的需求. 我看了网上很多文章的解决办法都无效 ...
- hdu 6082 度度熊与邪恶大魔王(2017"百度之星"程序设计大赛 - 资格赛 )
度度熊与邪恶大魔王 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total S ...
- P4135 作诗——分块
题目:https://www.luogu.org/problemnew/show/P4135 分块大法: 块之间记录答案,每一块记录次数前缀和: 注意每次把桶中需要用到位置赋值就好了: 为什么加了特判 ...
- bzoj 3172 单词
3172: [Tjoi2013]单词 Time Limit: 10 Sec Memory Limit: 512 MBSubmit: 3937 Solved: 1912[Submit][Status ...