期望得分: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的更多相关文章

  1. NOIP模拟赛20161022

    NOIP模拟赛2016-10-22 题目名 东风谷早苗 西行寺幽幽子 琪露诺 上白泽慧音 源文件 robot.cpp/c/pas spring.cpp/c/pas iceroad.cpp/c/pas ...

  2. contesthunter暑假NOIP模拟赛第一场题解

    contesthunter暑假NOIP模拟赛#1题解: 第一题:杯具大派送 水题.枚举A,B的公约数即可. #include <algorithm> #include <cmath& ...

  3. NOIP模拟赛 by hzwer

    2015年10月04日NOIP模拟赛 by hzwer    (这是小奇=> 小奇挖矿2(mining) [题目背景] 小奇飞船的钻头开启了无限耐久+精准采集模式!这次它要将原矿运到泛光之源的矿 ...

  4. 大家AK杯 灰天飞雁NOIP模拟赛题解/数据/标程

    数据 http://files.cnblogs.com/htfy/data.zip 简要题解 桌球碰撞 纯模拟,注意一开始就在袋口和v=0的情况.v和坐标可以是小数.为保险起见最好用extended/ ...

  5. 队爷的讲学计划 CH Round #59 - OrzCC杯NOIP模拟赛day1

    题目:http://ch.ezoj.tk/contest/CH%20Round%20%2359%20-%20OrzCC杯NOIP模拟赛day1/队爷的讲学计划 题解:刚开始理解题意理解了好半天,然后发 ...

  6. 队爷的Au Plan CH Round #59 - OrzCC杯NOIP模拟赛day1

    题目:http://ch.ezoj.tk/contest/CH%20Round%20%2359%20-%20OrzCC杯NOIP模拟赛day1/队爷的Au%20Plan 题解:看了题之后觉得肯定是DP ...

  7. 队爷的新书 CH Round #59 - OrzCC杯NOIP模拟赛day1

    题目:http://ch.ezoj.tk/contest/CH%20Round%20%2359%20-%20OrzCC杯NOIP模拟赛day1/队爷的新书 题解:看到这题就想到了 poetize 的封 ...

  8. CH Round #58 - OrzCC杯noip模拟赛day2

    A:颜色问题 题目:http://ch.ezoj.tk/contest/CH%20Round%20%2358%20-%20OrzCC杯noip模拟赛day2/颜色问题 题解:算一下每个仆人到它的目的地 ...

  9. CH Round #52 - Thinking Bear #1 (NOIP模拟赛)

    A.拆地毯 题目:http://www.contesthunter.org/contest/CH%20Round%20%2352%20-%20Thinking%20Bear%20%231%20(NOI ...

  10. CH Round #49 - Streaming #4 (NOIP模拟赛Day2)

    A.二叉树的的根 题目:http://www.contesthunter.org/contest/CH%20Round%20%2349%20-%20Streaming%20%234%20(NOIP 模 ...

随机推荐

  1. Friends and Cookies(思维)

    Abood's birthday has come, and his n friends are aligned in a single line from 1 to n, waiting for t ...

  2. ubuntu安装和查看已安装软件

    说明:由于图形化界面方法(如Add/Remove... 和Synaptic Package Manageer)比较简单,所以这里主要总结在终端通过命令行方式进行的软件包安装.卸载和删除的方法. 一.U ...

  3. 如何在一台 web 服务器上注册CA证书

    试验环境介绍(CA的主机为192.168.23.10.httpd的主机为:192.168.23.11) 1:新建一台web服务器,主机名为www yum install -y httpd   2:生成 ...

  4. 第六周PSP &进度条

    团队项目PSP 一.表格:     C类型 C内容 S开始时间 E结束时间 I时间间隔 T净时间(mins) 预计花费时间(mins) 讨论 讨论alpha完成情况并总结 9:40 11:20 17 ...

  5. vue+postcss报错: variable '--primary-color' is undefined and used without a fallback

    之前vue-cli3引入postcss的配置: https://www.cnblogs.com/XHappyness/p/7676680.html 发现这么一个问题,我再全局global.css中定义 ...

  6. vue shorthands

    vue shorthands : & @ https://vuejs.org/v2/guide/syntax.html#Shorthands v-for https://vuejs.org/v ...

  7. [LeetCode] Search in Rotated Array

    Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 migh ...

  8. SQL中 ALL 和 ANY 区别的

    在select中我们可能会认为all和any应该表达的意思差不多.其实他们的意思完全不一样: all: 是将后面的内容看成一个整体,如: >all (select age from studen ...

  9. java利用poi读取excel异常问题

    最近一个web工程需要完成一个小功能,利用文件上传然后读取文件内容写入到数据库,这里是操作的excel文件,excel文件分两种后缀,03版本的xls和之后的xlsx,现在大家一般都拿非常好用的插件直 ...

  10. C++解析-外传篇(3):动态内存申请的结果

    0.目录 1.动态内存申请一定成功吗? 2.new_handler() 函数 3.小结 1.动态内存申请一定成功吗? 问题: 动态内存申请一定成功吗? 常见的动态内存分配代码: C代码: C++代码: ...