NOIP模拟5
期望得分:100+100+100=300
实际得分:72+12+0=84
T1 [CQOI2009]中位数图
令c[i]表示前i个数中,比d大的数与比d小的数的差,那么如果c[l]=c[r],则[l+1,r]满足条件
#include<cstdio>
#include<iostream>
using namespace std;
const int N=1e7;
int c[N*],g[N];
void read(int &x)
{
x=; char c=getchar();
while(!isdigit(c)) c=getchar();
while(isdigit(c)) { x=x*+c-''; c=getchar();}
}
int main()
{ int n,d,x,now=,pos;
long long ans=;
bool ok=false;
read(n); read(d);
c[n]=;
for(int i=;i<=n;i++)
{
read(x);
if(x<d) now--;
else if(x>d) now++;
if(x==d) ok=true,pos=i;
if(!ok) c[now+n]++;
else g[i]=now;
}
for(int i=pos;i<=n;i++) ans+=c[g[i]+n];
printf("%lld",ans);
}
T2 #515. 「LibreOJ β Round #2」贪心只能过样例
dp[i][j] 表示到第i个数,能否凑出j
枚举第i个数能填的数v
dp[i][j]=dp[i-1][j-v*v]
bitset优化
#include<bitset>
#include<cstdio>
using namespace std;
const int MAXN=;
bitset<MAXN>b[];
int main()
{
//freopen("kinds.in","r",stdin);
//freopen("kinds.out","w",stdout);
int n,l,r;
scanf("%d",&n);
b[]^=;
for(int i=;i<=n;i++)
{
scanf("%d%d",&l,&r);
for(int j=l;j<=r;j++) b[i]|=b[i-]<<(j*j);
}
printf("%d",b[n].count());
}
T3
按截距排序之后区间DP
#include<cmath>
#include<cstdio>
#include<iostream>
#include<algorithm>
#define N 2001
using namespace std;
void read(int &x)
{
x=0; int f=1; char c=getchar();
while(!isdigit(c)) { if(c=='-') f=-1; c=getchar(); }
while(isdigit(c)) { x=x*10+c-'0'; c=getchar();}
x*=f;
}
struct node
{
int x,y,v,c,cnt;
double b;
}e[N];
double k;
const double pi=3.1415926;
const double eps=1e-12;
double dp[N];
double prec[N],prev[N];
int s[N];
double cal(int i)
{
return e[i].y-k*e[i].x;
}
bool cmp(node p,node q)
{
return p.b<q.b;
}
int main()
{
//freopen("yuuka.in","r",stdin);
//freopen("yuuka.out","w",stdout);
int n,kk;
read(n);
for(int i=1;i<=n;i++) read(e[i].x),read(e[i].y),read(e[i].v),read(e[i].c);
read(kk);
if(kk)
{
k=tan(pi*kk/180);
for(int i=1;i<=n;i++) e[i].b=cal(i),e[i].cnt=1;
}
else for(int i=1;i<=n;i++) e[i].b=e[i].y,e[i].cnt=1;
sort(e+1,e+n+1,cmp);
int tot=1;
for(int i=2;i<=n;i++)
if(fabs(e[i].b-e[i-1].b)<eps) e[tot].v+=e[i].v,e[tot].c+=e[i].c,e[tot].cnt+=e[i].cnt;
else e[++tot]=e[i];
for(int i=1;i<=tot;i++) s[i]=s[i-1]+e[i].cnt,prec[i]=prec[i-1]+e[i].c,prev[i]=prev[i-1]+e[i].v;
dp[1]=e[1].v*e[1].c*1.0/e[1].cnt;
for(int i=2;i<=tot;i++)
for(int j=0;j<i;j++)
dp[i]=max(dp[i],dp[j]+(prec[i]-prec[j])*(prev[i]-prev[j])*1.0/(s[i]-s[j]));
printf("%.3lf",dp[tot]);
// for(int i=1;i<=tot;i++) printf("%.3lf\n",dp[i]);
}
NOIP模拟5的更多相关文章
- NOIP模拟赛20161022
NOIP模拟赛2016-10-22 题目名 东风谷早苗 西行寺幽幽子 琪露诺 上白泽慧音 源文件 robot.cpp/c/pas spring.cpp/c/pas iceroad.cpp/c/pas ...
- contesthunter暑假NOIP模拟赛第一场题解
contesthunter暑假NOIP模拟赛#1题解: 第一题:杯具大派送 水题.枚举A,B的公约数即可. #include <algorithm> #include <cmath& ...
- NOIP模拟赛 by hzwer
2015年10月04日NOIP模拟赛 by hzwer (这是小奇=> 小奇挖矿2(mining) [题目背景] 小奇飞船的钻头开启了无限耐久+精准采集模式!这次它要将原矿运到泛光之源的矿 ...
- 大家AK杯 灰天飞雁NOIP模拟赛题解/数据/标程
数据 http://files.cnblogs.com/htfy/data.zip 简要题解 桌球碰撞 纯模拟,注意一开始就在袋口和v=0的情况.v和坐标可以是小数.为保险起见最好用extended/ ...
- 队爷的讲学计划 CH Round #59 - OrzCC杯NOIP模拟赛day1
题目:http://ch.ezoj.tk/contest/CH%20Round%20%2359%20-%20OrzCC杯NOIP模拟赛day1/队爷的讲学计划 题解:刚开始理解题意理解了好半天,然后发 ...
- 队爷的Au Plan CH Round #59 - OrzCC杯NOIP模拟赛day1
题目:http://ch.ezoj.tk/contest/CH%20Round%20%2359%20-%20OrzCC杯NOIP模拟赛day1/队爷的Au%20Plan 题解:看了题之后觉得肯定是DP ...
- 队爷的新书 CH Round #59 - OrzCC杯NOIP模拟赛day1
题目:http://ch.ezoj.tk/contest/CH%20Round%20%2359%20-%20OrzCC杯NOIP模拟赛day1/队爷的新书 题解:看到这题就想到了 poetize 的封 ...
- CH Round #58 - OrzCC杯noip模拟赛day2
A:颜色问题 题目:http://ch.ezoj.tk/contest/CH%20Round%20%2358%20-%20OrzCC杯noip模拟赛day2/颜色问题 题解:算一下每个仆人到它的目的地 ...
- CH Round #52 - Thinking Bear #1 (NOIP模拟赛)
A.拆地毯 题目:http://www.contesthunter.org/contest/CH%20Round%20%2352%20-%20Thinking%20Bear%20%231%20(NOI ...
- CH Round #49 - Streaming #4 (NOIP模拟赛Day2)
A.二叉树的的根 题目:http://www.contesthunter.org/contest/CH%20Round%20%2349%20-%20Streaming%20%234%20(NOIP 模 ...
随机推荐
- “Hello World!”团队——Final发布用户使用报告
博客内容: 1.用户体验报告表 2.用户评论截图 3.总结 一.用户体验报告表 用户使用报告 用户类别 用户姓名(化名) 性别 用户职业 使用频次 用户评论 新增用户 小小静 女 中学信息技术老师 8 ...
- 王者荣耀交流协会final冲刺第五次scrum会议
成员王超,高远博,冉华,王磊,王玉玲,任思佳,袁玥全部到齐,王磊拍照. master:高远博 2.时间跨度 2017年12月5日 18:00 - 18:31,总计31分钟 3.地点 一食堂二楼沙发座椅 ...
- 20170928-3 四则运算psp
1.本周psp: 2.本周进度条: 3.累计进度图(折线图): 4.psp饼状图:
- 20172332『Java程序设计』课程结对编程练习_四则运算第二周阶段总结
20172313『Java程序设计』课程结对编程练习_四则运算第二周阶段总结 小组成员 20172326康皓越 20172313余坤澎 20172332于欣月 小组编程照片 设计思路 设计一个生成符号 ...
- Alpha 冲刺(4/10)
队名 火箭少男100 组长博客 林燊大哥 作业博客 Alpha 冲鸭鸭鸭鸭! 成员冲刺阶段情况 林燊(组长) 过去两天完成了哪些任务 协调各成员之间的工作 协助前后端接口的开发 测试项目运行的服务器环 ...
- Java中的生产者、消费者问题
Java中的生产者.消费者问题描述: 生产者-消费者(producer-consumer)问题, 也称作有界缓冲区(bounded-buffer)问题, 两个进程共享一个公共的固定大小的缓冲区(仓库) ...
- C++对象内存布局测试总结
C++对象内存布局测试总结 http://hi.baidu.com/����/blog/item/826d38ff13c32e3a5d6008e8.html 上文是半年前对虚函数.虚拟继承的理解.可能 ...
- 【第四周】psp
代码累计 300+575+475+353=1603 随笔字数 1700+3000+3785+4210=12695 知识点 QT框架 Myeclipse基础环境 代码复用,封装 Ps技术 在excel画 ...
- PAT L1-032 Left-pad
https://pintia.cn/problem-sets/994805046380707840/problems/994805100684361728 根据新浪微博上的消息,有一位开发者不满NPM ...
- PAT 甲级 1008 Elevator
https://pintia.cn/problem-sets/994805342720868352/problems/994805511923286016 The highest building i ...