#include <iostream> #include <stdio.h> #include <string.h> #include <stdlib.h> #include <cmath> #include <algorithm> #include <algorithm> using namespace std; #pragma warning(disable:4996) int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) { int m; int x[1000]; scanf("%d", &m); for (int i = 0; i < m; i++) { scanf("%d", &x[i]); } sort(x, x + m); int max = 0; int y; for (int i = m-1; i >=0; i--) { y = x[i] * (m - i); if (y > max) { max = y; } } printf("%d\n", max); } return 0; } |
Double click to view unformatted code.