博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ACM-ICPC国际大学生程序设计竞赛北京赛区(2017)网络赛 A题 Visiting Peking University...
阅读量:5226 次
发布时间:2019-06-14

本文共 2986 字,大约阅读时间需要 9 分钟。

题目1 : Visiting Peking University

时间限制:1000ms

单点时限:1000ms

内存限制:256MB

描述

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

Unfortunately, Ming comes to know that traffic control will betaking place in Beijing on some days during his n-day trip, and he won’t beable 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 visitinteresting 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 trafficcontrol days among those k days. Under this complicated situation, he doesn’tknow how to make the best schedule. Please write a program to help Mingdetermine the best dates of the two days to visit Peking University.  Dataguarantees 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 thetotal number of traffic control days during the n-day trip, followed by q integersrepresenting the dates of these days.

输出

One line, including two integers a and b, representing the bestdates 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

/*题意是有多组数组输入每组数据第一行输入两个整数n ,m 第二行有n个数,分别代表第0,1,2....n-1天在北京大学等待的人数第三行输入一个k个数,接下来又有k个数表示交通限制的日期是多少现在要从没被限制交通的日期里面选择连续的m天去到北大旅行,在m天里面选择两天(这两天的第一天必须是连续m天中的第一天,两天中的等待人数之和又必须是最小)最后输出连续的m天中选择的两天的日期是多少*/
#include 
using namespace std; struct aa { int which_day; int wait_people; }a[101]; int main() { int all_wait_people[101]; int n,m,limit_days; while(cin>>n>>m) { for(int i=0;i
>all_wait_people[i]; cin>>limit_days; int day; for(int i=0;i
>day; all_wait_people[day]=-1; } int j=0; for(int i=0;i
#include
using namespace std;#define MAX 1005struct Node{ int data; int num;};int main(){ int n,m; Node p[MAX],P[MAX]; while(scanf("%d%d",&n,&m)!=EOF) { int i; for(i=0;i

转载于:https://www.cnblogs.com/sxy201658506207/p/7586251.html

你可能感兴趣的文章
路冉的JavaScript学习笔记-2015年1月23日
查看>>
Mysql出现(10061)错误提示的暴力解决办法
查看>>
2018-2019-2 网络对抗技术 20165202 Exp3 免杀原理与实践
查看>>
NPM慢怎么办 - nrm切换资源镜像
查看>>
Swift - UIView的常用属性和常用方法总结
查看>>
Swift - 异步加载各网站的favicon图标,并在单元格中显示
查看>>
【Python学习笔记】1.基础知识
查看>>
梦断代码阅读笔记02
查看>>
selenium学习中遇到的问题
查看>>
大数据学习之一——了解简单概念
查看>>
Linux升级内核教程(CentOS7)
查看>>
Lintcode: Partition Array
查看>>
类别的三个作用
查看>>
Maximum Product Subarray
查看>>
[转载] MySQL的四种事务隔离级别
查看>>
QT文件读写
查看>>
C语言小项目-火车票订票系统
查看>>
[Linux]PHP-FPM与NGINX的两种通讯方式
查看>>
Java实现二分查找
查看>>
优秀员工一定要升职吗
查看>>