题意: 给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