IOI 2011 | Practice task
Thailand is a tropical country. Thai people usually say that Thailand
has 3 seasons: Hot Summer, Hotter Summer, and Hottest Summer. It
especially feels very hot when you have many consecutive days with
You are planning a K-day trip to Thailand. Since you would like
to experience the real Thai Summer, you want your stay to be as hot as
You are given a list of forecasted temperatures of N consecutive
days. You would like to find the maximum sum of temperatures of K
consecutive days. It is guaranteed that 1 <= K <= N.
You are to implement procedure
maxk(N,T,K) that returns the
maximum sum of temperatures of any K consecutive days, where
N is the number of days and
T is an array of positive
T[i], for 0 <= i < N, is the temperature of
Suppose that N=6, K=3 and T = 10 50 30 20 5 1.
There are 4 possible 3-day trips, starting from day 0, day 1, day 2,
and day 3; and their sum of temperatures are 90, 100, 55, and 26.
maxk should return 100.
Subtask 1 (50 points)
- N <= 1 000, 0 < T[i] <= 1 000
Subtask 2 (50 points)
- N <= 1 000 000, 0 < T[i] <= 1 000
- Use the RunC programming and test environment. (See the contest environment information here)
- Implementation folder:
hottest/ (download prototype here)
- To be implemented by contestant:
- Contestant interface:
- Grader interface: none
- Sample grader:
- Sample grader input:
Note: the sample grader reads N, K, and Ti's, and the expected solution from standard input.
- Expected output for sample grader input:
- Compile and run (command line):
runc grader.c or
runc grader.cpp or
runc g rader.pas
- Compile and run (gedit plugin): Control-R, while editing any implementation or grader file.
- CPU time limit: 2 seconds
- Memory limit: 256 MB