[dp]Codeforces30C Shooting Gallery
题意: 给n个点 每个点的坐标 x y 出现的时间t 射中的概率
从i点到j点的时间为它们的距离.
求射中个数的最大期望
很水的dp 坑点就是要用LL
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cctype>
#include <cmath>
#include <string>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;
#include <queue>
#include <stack>
#include <vector>
#include <deque>
#include <set>
#include <map>
typedef long long LL;
typedef long double LD;
#define pi acos(-1.0)
#define lson l, m, rt<<1
#define rson m+1, r, rt<<1|1
typedef pair<int, int> PI;
typedef pair<int, PI> PP;
#ifdef _WIN32
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
//#pragma comment(linker, "/STACK:1024000000,1024000000")
//LL quick(LL a, LL b){LL ans=1;while(b){if(b & 1)ans*=a;a=a*a;b>>=1;}return ans;}
//inline int read(){char ch=' ';int ans=0;while(ch<'0' || ch>'9')ch=getchar();while(ch<='9' && ch>='0'){ans=ans*10+ch-'0';ch=getchar();}return ans;}
//inline void print(LL x){printf(LLD, x);puts("");}
//inline void read(double &x){char c = getchar();while(c < '0') c = getchar();x = c - '0'; c = getchar();while(c >= '0'){x = x * 10 + (c - '0'); c = getchar();}} const double eps=1e-;
struct node
{
LL x, y, t;
double p;
}a[];
double dp[];
bool cmp(node a, node b)
{
return a.t<b.t;
}
int main()
{
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
#endif
int n;
while(~scanf("%d", &n))
{
for(int i=;i<n;i++)
{
scanf(LLD, &a[i].x);
scanf(LLD, &a[i].y);
scanf(LLD, &a[i].t);
scanf("%lf", &a[i].p);
}
sort(a, a+n, cmp);
memset(dp, , sizeof(dp));
for(int i=;i<n;i++)
{
dp[i]=a[i].p;
for(int j=;j<i;j++)
if((a[j].x-a[i].x)*(a[j].x-a[i].x)+(a[j].y-a[i].y)*(a[j].y-a[i].y)<=(a[j].t-a[i].t)*(a[j].t-a[i].t)+eps)
dp[i]=max(dp[i], a[i].p+dp[j]);
}
double ans=;
for(int i=;i<n;i++)
ans=max(ans, dp[i]);
printf("%.10lf\n", ans);
}
return ;
}
Codeforces 30C
[dp]Codeforces30C Shooting Gallery的更多相关文章
- 【20.00%】【codeforces 44G】Shooting Gallery
time limit per test5 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- 【16.50%】【CF 44G】Shooting Gallery
time limit per test 5 seconds memory limit per test 256 megabytes input standard input output standa ...
- CodeForces 30C Shooting Gallery 简单dp
版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/qq574857122/article/details/36944227 题目链接:点击打开链接 给定 ...
- Gym - 101670F Shooting Gallery(CTU Open Contest 2017 区间dp)
题目&题意:(有点难读...) 给出一个数字序列,找出一个区间,当删除这个区间中的两个相同的数字后,只保留这两个数字之间的序列,然后继续删除相同的数字,问最多可以实行多少次删除操作. 例如: ...
- CTU OPEN 2017 Shooting Gallery /// 区间DP
题目大意: 给定n 给定n个数 选定一个区间留下其他消去 要求区间两端的两个数一样 若成功留下一个区间 则在选定区间的基础上 继续进行上述操作 直到无法再选出这样的区间 求最多操作数 按区间长度由短到 ...
- CF dp 题(1500-2000难度)
前言 从后往前刷 update 新增 \(\text{\color{red}{Mark}}\) 标记功能,有一定难度的题标记为 \(\text{\color{red}{红}}\) 色. 题单 (刷过的 ...
- mark一下咕掉的题目
蒟蒻才普及组呀~ 大佬别D我 等集中补一下 CF980F:咋说捏,我觉得要联赛了做这题有点浪费时间,等想颓废了再来写写叭qwq 215E/279D/288E/331C3/431D/433E/750G/ ...
- [Unity3D]Unity资料大全免费分享
都是网上找的连七八糟的资料了,整理好分享的,有学习资料,视频,源码,插件……等等 东西比较多,不是所有的都是你需要的,可以按 ctrl+F 来搜索你要的东西,如果有广告,不用理会,关掉就可以了,如 ...
- Android -- ImageSwitch和Gallery 混合使用
1. 实现效果
随机推荐
- ASP实现清除HTML标签,清除 空格等编码
'清除HTML格式 Function RemoveHTML(strText) Dim RegEx Set RegEx = New RegExp RegEx.Global = True '清除HTML标 ...
- Fragment的数据传递
开发之中用到的Fragment的次数越来越多,很多小的项目都已经直接在使用Fragment作为Activity的载体来切换页面.而在开发之中页面的切换我们最关心的问题就是数据的传递了.今天我们主要来研 ...
- ACM——快速排序法
快速排序 时间限制(普通/Java):1000MS/3000MS 运行内存限制:65536KByte总提交:653 测试通过:297 描述 给定输入排序元素数目 ...
- items 与iteritems
dict的items函数返回的是键值对的元组的列表,而iteritems使用的是键值对的generator. items当使用时会调用整个列表 iteritems当使用时只会调用值. >> ...
- Jquery on 事件
$(document).on("click", 'a.AAA', function(){ var flag=$(this).attr('flag'); alert(flag); } ...
- $.get
$('#choice').change(function() { if($(this).val() != '') { $.get( 'data.php', { what: $(this).val() ...
- iOS开发——https+证书
由于公司项目的需要,经过调研后,已成功. 同事已把此问题写成博客<[加密解密]HTTPS>,我就直接转用了 附带链接如下: http://www.jianshu.com/p/8351917 ...
- 输出一个等边三角形的字母阵,等边三角形的两腰为字母A,往里靠依次字母大一个(详细题目文章中描述)
题目简单的描述就是输出这么一个金字塔型的字母阵(等边三角形) /* A ABA ABCBA */ /* //解法①:对称轴法 #import <stdio.h> int main() { ...
- leetcode之Rectangle Area
Find the total area covered by two rectilinear rectangles in a 2D plane. Each rectangle is defined b ...
- infopath 之绑定列表 数据源
在psd中启动infopath更新表单模版 注:虽然可能在infopath design中预览的时候会报错说是跨域数据不能加载,别理他 继续发布上站点就不会有这个错误了. 绑定list后效果: 参考u ...