北京赛区(2017)网络赛 之 Visiting Peking University

本文介绍了一个算法问题,即如何为一位旅行者规划在北京的最佳访问北京大学日期,以避开等待队伍并考虑交通管制因素。该问题涉及动态规划和最优选择策略。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

题目1 : Visiting Peking University

时间限制:1000ms
单点时限:1000ms
内存限制:256MB

描述

Ming is going to travel for n days and the date of these days can be represented by n integers: 0, 1, 2, …, n-1. He plans to spend m consecutive days(2 ≤ m ≤ n)in Beijing. During these m days, he intends to use the first day and another day to visit Peking university. Before he made his plan, Ming investigated on the number of tourists who would be waiting in line to enter Peking university during his n-day trip, and the results could be represented by an integer sequence p[i] (0 ≤ i ≤ n-1, p[i] represents the number of waiting tourists on day i). To save time, he hopes to choose two certain dates a and b to visit PKU(0 ≤ a < b ≤ n-1), which makes p[a] + p[b] as small as possible.

Unfortunately, Ming comes to know that traffic control will be taking place in Beijing on some days during his n-day trip, and he won’t be able to visit any place in Beijing, including PKU, on a traffic control day. Ming loves Beijing and he wants to make sure that m days can be used to visit interesting places in Beijing. So Ming made a decision:  spending k (m ≤ k ≤ n) consecutive days in Beijing is also acceptable if there are k - m traffic control days among those k days. Under this complicated situation, he doesn’t know how to make the best schedule. Please write a program to help Ming determine the best dates of the two days to visit Peking University.  Data guarantees a unique solution.

输入

There are no more than 20 test cases.

For each test case:

The first line contains two integers, above mentioned n and m (2 ≤ n ≤ 100, 2 ≤ m ≤ n).

The second line contains n integers, above mentioned p[0] , p[1] , … p[n-1]. (0 ≤ p[i] ≤ 1000, i = 0 ... n-1)

The third line is an integer q (0 ≤ q ≤ n), representing the total number of traffic control days during the n-day trip, followed by q integers representing the dates of these days.

输出

One line, including two integers a and b, representing the best dates for visiting PKU.

样例输入
7 3
6 9 10 1 0 8 35
3 5 6 2
4 2
10 11 1 2
1 2
样例输出
0 3

1 3


AC代码如下:

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

const int maxn=100+10;
int p[maxn];
int q[maxn];
int flag[maxn];

struct point
{
    int value;
    int id;
}a[maxn];

int main()
{
    int n,m;
    int l,r;
    int q_num;
    while(cin>>n>>m)
    {
        memset(p,0,sizeof(p));
        memset(q,0,sizeof(q));
        memset(a,0,sizeof(a));
        memset(flag,0,sizeof(flag));

        for(int i=0;i<n;i++) cin>>p[i];
        cin>>q_num;
        for(int i=0;i<q_num;i++)
        {
            cin>>q[i];
            flag[q[i]]=1;
        }
        int num=0;
        for(int i=0;i<n;i++)
        {
            if(!flag[i])
            {
                a[num].value=p[i];
                a[num].id=i;
                num++;
            }
        }

        int maxi=10000;
        for(int i=0;i<num;i++)
        {
            if(i+m-1<num)
            {
                 for(int j=i+1;j<=i+m-1;j++)
                 {
                    if(a[i].value+a[j].value<maxi)
                    {
                        maxi=a[i].value+a[j].value;
                        l=a[i].id;
                        r=a[j].id;
                    }
                 }

            }
        }
        cout<<l<<" "<<r<<endl;
    }
    return 0;
}



分析师通过访问上市公司能否获得信息优势是一个有争议的问题。一些人认为访问上市公司确实能够提供额外的信息,从而帮助分析师更好地了解公司的运营状况和未来发展趋势。访问过程中,分析师可以与公司高层管理人员、财务主管以及其他关键人物进行面对面的交流。通过这种交流,他们可以获取公司的战略规划、财务状况、市场竞争情况等敏感和关键的信息。 另外,访问上市公司还可以帮助分析师更好地了解公司的营销策略、产品研发进展以及行业趋势。他们可以实地考察公司的生产基地、产品展示以及市场地位,从而对公司的未来前景有更准确的评估。 然而,也有人认为访问上市公司并不能给分析师带来信息优势。首先,上市公司往往对外人保持谨慎,会有所保留关键信息,因此分析师难以获取到真实而详尽的信息。其次,访问上市公司需要耗费时间和金钱,并不能保证获得有价值的信息,因此从成本效益的角度考虑,分析师可能不会选择进行频繁的公司访问。 综上所述,分析师访问上市公司是否能获得信息优势存在争议。尽管访问过程中可以获取到公司的重要信息,但由于访问的限制和成本考量,不能确保获得持续和有效的信息优势。因此,分析师在评估公司时应综合考虑各种信息来源,并进行全面而准确的分析。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值