题目链接 题意:给出n个元素的序列,求出最大的a[i]%a[j] (i>=j) 思路:没思路。。。。
Let us iterate over all different a__j. Since we need to maximize , then iterate all integer x (such_x_ divisible by a__j) in range from 2_a__j_ to M, where M — doubled maximum value of the sequence. For each such x we need to find maximum a__i, such a__i < x. Limits for numbers allow to do this in time O(1) with an array. After that, update answer by value . Total time complexity is O(nlogn + MlogM)
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
Petya loves computer games. Finally a game that he’s been waiting for so long came out!
The main character of this game has n different skills, each of which is characterized by an integer a__i from 0 to 100. The higher the number_a__i_ is, the higher is the i-th skill of the character. The total rating of the character is calculated as the sum of the values of for all i from 1 to n. The expression ⌊ x⌋ denotes the result of rounding the number x down to the nearest integer.