1 /* 2 我校oj的源题,看懂题意就很水,贴出来省的再敲:) 3 */ 4 #include <cstdio> 5 #include <algorithm> 6 #include <cstring> 7 using namespace std; 8 9 const int MAXN = 1e3 + 10; 10 const int INF = 0x3f3f3f3f; 11 int a[MAXN]; 12 13 int main(void) //POJ 2291 Rotten Ropes 14 { 15 int t, n; scanf ("%d", &t); 16 while (t--) 17 { 18 scanf ("%d", &n); 19 for (int i=1; i<=n; ++i) scanf ("%d", &a[i]); 20 sort (a+1, a+1+n); 21 int ans = 0; int m = n; 22 for (int i=1; i<=n; ++i) 23 { 24 ans = max (ans, m * a[i]); 25 m--; 26 } 27 28 printf ("%d\n", ans); 29 } 30 31 return 0; 32 }
时间: 2024-11-09 07:36:17