1628 Pizza Delivery

There is a pizza house located on a straight road, and there are many houses along the road which are
customers to the pizza house. To attract more orders from his customers, the owner of the pizza house
advertised that he will deduct a penalty for late delivery from the price of the delivered pizzas. The
penalty is to be charged when some designated time period has passed after the order has been made,
and the amount of penalty to be charged is 1 Korean Won per unit time thereafter. Today all houses on
the road ordered pizza at the same time and the delivery of all the ordered pizzas has just started when
the late delivery penalty is going to be charged. On a busy day like today, he may not deliver pizza to
some customers if the late delivery penalty to be deducted for a customer is more than the earning to
be made by selling pizza to the customer. Write a program to help him decide to which customers he
has to deliver pizzas and which customers he may skip in order to make the greatest pro t. Note that
the pro t made by delivering a pizza to a customer is the amount of earning from the service deducting
the penalty for late delivery. You may assume that his moving velocity is one unit distance per unit
time and it takes no time to hand over the pizza to the customer.
For example, the following gure shows the relative positions of ve customers fc1; c2; : : : ; c5g to
the pizza house and the earning to be made by selling pizzas to each customer.
If the delivering sequence of customers is < c4; c3; c2; c5; c1 >, then the amount of penalty for late
delivery to each customer is 2 for c4, 5 for c3, 7 for c2, 15 for c5 and 26 for c1. In this case the pro t from
each customer is 3 for c4, -3 for c3, 3 for c2, 5 for c5 and 1 for c1. Since the pro t from customer c3 is -3,
it is better not to deliver pizza to c3. Therefore the total pro t by delivering pizzas to the customers in
this order is 12. The best pro t the owner can make, in this case, is 32, where the delivering sequence
is < c3; c2; c1; c5 >.
Given the relative positions of customers to pizza house, and earnings to be made by delivering
pizzas to each customer, write a program to compute the maximum pro ts by delivering pizzas ordered
from the customers.
Input
Your program is to read from standard input. The input consists of T test cases. The number of test
cases T is given in the rst line of the input. Each test case consists of three lines. The rst line of
each test case contains an integer, n (1 n 100), which is the number of customers to pizza house.
The second line of each test case contains n integers p1, p2, … , pn (p1 < p2 < : : : < pn and pi = 0, ̸
i = 1; : : : ; n), where pi
is the relative position of the i-th customer ci to the pizza house on the straight
road. The third line of each test case contains n integers e1, e2, … , en (ei > 0, i = 1; : : : ; n), where eiUniversidad de Valladolid OJ: 1628 { Pizza Delivery 2/2
is the earning to be made by delivering pizzas to the customer ci
. All integers in the second and third
lines are between -100,000 and 100,000 both inclusive.
Output
Your program is to write to standard output. Print exactly one line for each test case. The line should
contain the maximum pro t by delivering pizzas ordered from the customers.
The following shows sample input and output for three test cases.
Sample Input
3
5
-6 -3 -1 2 5
27 10 2 5 20
6
1 2 4 7 11 14
3 6 2 5 18 10
11
-14 -13 -12 -11 -10 1 2 3 4 5 100
200 200 200 200 200 200 200 200 200 200 200
Sample Output
32
13
1937

有一个披萨的房子位于直路,还有很多房子的路
客户的披萨。吸引更多的订单从他的客户,披萨的主人的房子
广告,他将从价格中扣除惩罚延误发货的比萨饼交付。的
惩罚时要收取一些订单后指定时间已经过了,
和被处罚的数量是1韩元单位时间。今天,所有的房屋
路同时订购比萨饼和交付的所有订购比萨饼刚刚开始的时候
迟交罚款将被起诉。在今天这样一个忙碌的一天,他可能不会提供披萨
一些客户如果迟交罚款扣除客户超过收入
由卖披萨给客户。编写一个程序来帮助他决定哪些客户
必须交付比萨饼和哪些客户可以跳过为了使最大的保护。请注意,
港由交付比萨饼客户从服务的收入扣除
惩罚延误发货。你可能认为他的移动速度是一个单位距离单位
需要时间和没有时间去比萨交给客户。
例如,下面的gure显示已经客户的相对位置fc1;c2,:::;c5g
披萨的房子和收入由卖披萨给每个客户。
如果客户的交付顺序是< c4、c3、c2、c5、c1 >,然后惩罚延误的数量
交付为c4每个客户是2、5 c3,c5 7 c2、15和26 c1。在这种情况下,普罗特
每个客户是3 c4,3为c3,3为c2 5 c5 1 c1。自普罗特从客户c3是3
最好是不提供比萨c3。因此,总普罗特向客户交付比萨饼
此订单是12。最好的普罗特所有者可以在这种情况下,是32,交付序列
是< c3,c2,c1,c5 >。
考虑到客户的相对位置披萨的房子,和收益是由交付
披萨给每个客户,写一个程序来计算最大防送批萨饼命令
从客户。
输入
程序从标准输入读取。输入包括T测试用例。测试的数量
案例中给出了T的第一行输入。每个测试用例包含三行。的第一行
每个测试用例包含一个整数,n(100 n),客户数量的披萨。
每个测试用例的第二行包含n个整数p1,p2,。pn(p1 < p2 <:::< pn和π= 0,̸
我= 1,:::;n),pi
的相对位置的第i个客户ci直上的披萨的房子吗
路。每个测试用例的第三行包含n个整数e1,e2,。,(ei > 0,我= 1,:::;n),eiUniversidad德巴利亚多利德橙汁:1628 {披萨外卖2/2
的收入是由客户ci送批萨饼
。第二个和第三个整数
行是在-100000年和100000年之间包容。
输出
你的程序是编写到标准输出。为每个测试用例完全打印一行。行应该
包含最大普罗特送批萨饼从客户订购。
下面显示了三个测试用例样本的输入和输出。
样例输入
3
5
6 3 1 2 5
27日20 10 2 5
6
1 2 4 7 11 14
3 6 2 5 18 10
11
-14 -13 -12 -11 -13 100 1 2 3 4 5
200 200 200 200 200 200 200 200 200 200 200
样例输出
32
13
1937
我有话说:
我简单的说一下题目大意。就是一个坐标轴上有n个客户。原点O是披萨店。一个送货员从店里出发送货。而每个客户支付的费用是ei-ti。ei是最初付款,ti是送到货等待的时间。求送货员最多获得的钱。

#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

const int maxn = 100 + 5;

int kase, n;
int p[maxn], v[maxn];
int d[maxn][maxn][maxn][2];
int vis[maxn][maxn][maxn][2];

//考虑s到e的所有的人都已经收到了货或者放弃送货。
// pos = 0意味在s, pos = 1意味在e,cnt是还需要送货的人数
int dp(int s, int e, int cnt, int pos) {
  if(cnt == 0) return 0;

  int &ans = d[s][e][cnt][pos];//当前状态最所能获得的钱
  if(vis[s][e][cnt][pos] == kase) return ans;//标记
  vis[s][e][cnt][pos] = kase;

  ans = 0;  
  if(!pos) {//在s
    for(int i = 0; i < s; i++)
      ans = max(ans, v[i] - cnt * abs(p[i] - p[s]) + dp(i, e, cnt - 1, 0));//意味着送到i需要的时间,再乘上所有剩下客户cnt就是总罚款数
    for(int i = e + 1; i < n; i++)
      ans = max(ans, v[i] - cnt * abs(p[i] - p[s]) + dp(s, i, cnt - 1, 1));
  }
  else {
    for(int i = 0; i < s; i++)
      ans = max(ans, v[i] - cnt * abs(p[i] - p[e]) + dp(i, e, cnt - 1, 0));
    for(int i = e + 1; i < n; i++)
      ans = max(ans, v[i] - cnt * abs(p[i] - p[e]) + dp(s, i, cnt - 1, 1));
  }
  return ans;
}

int main() {
  int T;
  scanf("%d",&T);
  memset(vis, 0, sizeof(vis));
  for(kase = 1; kase <= T; kase++) {
    scanf("%d", &n);
    for(int i = 0; i < n; i++) scanf("%d", &p[i]);
    for(int i = 0; i < n; i++) scanf("%d", &v[i]);

    int ans = 0;
    for(int k = 1; k <= n; k++)//选择要总共送货的客户的数量
      for(int i = 0; i < n; i++)//选择从哪个客户开始送货
        ans = max(ans, v[i] - k * abs(p[i]) + dp(i, i, k - 1, 0));
    printf("%d\n",ans);
  }
  return 0;
}
### 回答1: pizza pie charts(披萨饼图)是一种用于可视化数据的特殊类型的图表。它的形状类似于一块披萨,通常被用来表示和比较不同类别的占比或百分比。 披萨饼图通常由一个圆圈组成,圆圈的面积被划分为几个扇形,每个扇形代表一个数据类别。每个扇形的大小表示该类别在总体中所占的百分比。 例如,假设我们有一个销售数据集,包含了三个不同产品的销售额:产品A的销售额为10000元,产品B的销售额为20000元,产品C的销售额为30000元。我们可以使用披萨饼图将这些销售额占比可视化。由于产品A的销售额占总销售额的1/6,所以在披萨饼图中,产品A所占的扇形面积将等于1/6的整个圆圈面积。同样,产品B和产品C的扇形面积也分别等于1/3和1/2的整个圆圈面积。 披萨饼图的优点是直观易懂,能够清晰地展示各类别之间的相对大小。同时,披萨饼图还可以进行进一步的细分,通过将每个扇形进一步分割为更小的扇形,以显示更详细的数据。 然而,披萨饼图也存在一些限制。由于人类视觉对面积的感知存在偏差,大扇形和小扇形之间的面积差异可能会被过度夸大。此外,当涉及到大量数据类别时,披萨饼图可能会变得混乱和难以阅读。 总的来说,披萨饼图是一种简单有效的工具,能够帮助我们直观地理解和比较不同类别的占比。但是,在使用披萨饼图时,我们应该注意其局限性,结合具体情境和数据量进行选择。 ### 回答2: pizza pie chart是一种图表形式,用于呈现数据的比例关系。它的原理类似于披萨的切片,每个数据类别就像一块披萨的切片,其面积表示该类别在整体中所占的比例。 这种图表适用于有多个类别,并且可以清楚地比较它们之间的比例关系。例如,如果我们想要了解某家披萨餐厅每种口味的销售比例,我们可以使用pizza pie chart来展示每个口味所占的百分比。 在这个图表中,每个切片大小与对应数据的比例相等。切片可以按照顺时针或逆时针的方向排列。通常,图表的中心点被认为是100%的总和,其他切片则表示相对于该总和的百分比。 除了展示比例关系外,我们还可以使用这种图表来突出某个类别或者几个类别。例如,我们可以使用不同的颜色、阴影或者拉出一块切片来突出显示销售最好的口味。 总的来说,pizza pie chart是一种直观、易于理解的数据可视化工具,可以帮助我们更好地理解数据的比例关系。然而,也需要谨慎使用,尤其是当类别过多或者比例相近时,可能会导致图表的可读性下降。 ### 回答3: "Pizza pie charts"是一个把数据可视化呈现为披萨图形的术语。它源自术语"pie chart",它使用扇形切片来展示数据的比例关系。而"pizza"一词则是因为披萨形状与扇形切片相似。这种特殊的数据可视化方法通常用于简单的数据分析和展示。 使用pizza pie charts,我们可以快速了解不同数据元素之间的比例关系。每个扇形切片代表一个数据元素,而切片的大小表示数据元素在整体中所占的比例。通过颜色区分,我们可以更清楚地看到每个数据元素所占比例的多少。 与传统的条形图或折线图相比,pizza pie charts有其独特的优势和局限性。它们非常直观易懂,特别适用于显示相对较少的数据元素或数据元素的大致比例。然而,当数据元素较多或各个元素之间的差异很小时,使用该图形可能会变得混乱和难以理解。 因此,对于简单的分析和展示需求,使用pizza pie charts可以帮助我们更好地理解数据的比例关系。当我们需要更深入地分析和比较各个数据元素时,其他更适合的可视化方法可能会更加有效。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值