title 1:visiting Peking Universitytime limit: 1000mssingle point time limit: 1000msmemory limit: 256MBDescription
ming is going-travel for n days and the date of these days can be re Presented 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 being waiting in line to enter Peking Universi Ty during his n-day trips, and the results could be represented by an integer sequence P[i] (0≤i≤n-1, p[i] represents t He number of waiting tourists on day i). To save time, he hopes to choose-certain dates A and B to visit PKU (0≤a < b≤n-1), which makes P[a] + p[b] as SM All as possible.
Unfortunately, Ming comes to know that traffic control would be taking place in Beijing on some days during he n-day trip, And he won ' t is able to visit any place in Beijing, including PKU, on a traffic control day. Ming loves Beijing and he wants to make sure this m days can is used to visit interesting places in Beijing. So Ming made a decision:spending K (m≤k≤n) consecutive days in Beijing was 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. Ming determine the best dates of the "the" to visit Peking University. Data guarantees a unique solution.
input
There is no more than test cases.
For each test case:
The first line contains the 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 a integer q (0≤q≤n), representing the total number of traffic control days during the n-day-trip, F ollowed by q integers representing the dates of these days.
Output
One line, including-integers A and B, representing the best dates for visiting PKU.
-
- Sample input
-
-
7 36 9 10 1 0 8 353 5 6 24 210 11 1 21 2
-
- Sample output
-
0 31 3
"Test Instructions": Test instructions is a person to travel n days, in Beijing for a continuous m days, he wants to visit PKU, he knows the number of visitors queuing, but there is the Q-day traffic control, nowhere to go. So he decided to stay K days, but there is a requirement, in the first k days, as long as there is k~m days is the traffic control time, he can select any two days in a continuous M-day interval, ask the minimum number of queues, attention queuing number of subscript is 0~n-1, but the control days is 1-n, and finally output these two days (subscript).
"Analysis": The focus is on the lifting point of the day. The first set of data is 2, 6, and 5 days of traffic control, deleting them from the array. The remaining 6 (0) 9 (1) 1 (3) 0 (4). Three days combination->6 9 1 Select 2 days or 9 1 0. The minimum value is compared after summing. (Note that the first day of each case must be selected). You must choose the No. 0 or 1 days as the first day of the tour, or you cannot guarantee a total tour of m=3 days. If the No. 0 day starts, the best option is No. 0 and 3rd days, and the total number of queues is 6+1=7. If the 1th day is selected as the beginning, then the best option is 1th and 4th days, 9+0=9. So the final plan is the No. 0 and the 3rd day.
"Code":
#include <bits/stdc++.h>using namespacestd;Const intMAXN = the;#defineINF 0x3f3f3f3fstructnode{intRe,id;} B[MAXN];intMain () {intn,m,k; intA[MAXN]; intq,x; intVIS[MAXN]; while(~SCANF ("%d%d",&n,&m)) {k=0; memset (Vis,0,sizeof(VIS)); for(intI=0; i<n; i++) {scanf ("%d",&A[i]); } scanf ("%d",&q); for(intI=0; i<q; i++) {scanf ("%d",&x); VIS[X]=1; } for(intI=0; i<n;i++) { if(!Vis[i]) {B[k].re=A[i]; B[k++].id=i; //k++; } } intMinn=inf,l=0, r=0;// for(intI=0; i+m<=k;i++) { intx=b[i].re; for(intj=1; j<m;j++) { if(B[i+j].re+x <Minn) {Minn=b[i+j].re+x; L=b[i].id; R=b[i+j].id; }}} printf ("%d%d\n", L,r); }}
0ms
ACM-ICPC Beijing (2017) online Race 1 "Analog + enumeration + array Operations"