View Code of Problem 61

#include<stdio.h>
int main(){
	int t;
	scanf("%d",&t);//t组数据 
	while(t--){
		int n,t;
		scanf("%d",&n);//表示有几根绳子 
		int a[n];
		for(int i=0;i<n;i++){
			scanf("%d",&a[i]);
		}
		for(int i=0;i<n-1;i++){
			for(int j=0;j<n-i-1;j++){
				if(a[j+1]<a[j]){
					t=a[j];
					a[j]=a[j+1];
					a[j+1]=t;
				}
			}
		}
		//现在所有的绳子已经排序了
		int max=a[n-1];
		for(int i=0;i<n;i++){
			if(max<=a[i]*(n-i)){
				max=a[i]*(n-i);
			}
			
		}
		 
		printf("%d\n",max);
		
		
		
	}
	
	
	return 0;
}

Double click to view unformatted code.


Back to problem 61