Luogu.com is a collaboration of all interesting and challenging Computer Science problems from contests or Olympics.
In order to enrich the problem set and satisfy the needs of CS lovers and geeks, from then on, I will post the English version of all the problems on it, each of which is strictly labeled as the original.
For convenience and submitting format, I will prepare random inputs in the pastebin, once you have completed your program, you can test each of them to get an individual output, then you should submit the final answer based on the outputs (e.g. the sum of all the outputs).
Generally, the running time should be less than for all given inputs. Although I've no methods to test the running time, the size of the input should help.
You can use any programming language as you want.
Your algorithm should be always correct for all the circumstances.
Welcome to challenge the problem set :)