2 solutions

  • 1
    @ 2026-8-18 13:52:14
    
    #include<bits/stdc++.h>
    using namespace std;
    int a[1110];
    int main()
    {
    	int n,k,s=0,ma=0;
    	cin>>n>>k;
    	for(int i=1;i<=n;i++)
    	{
    		cin>>a[i];
    	}
    	sort(a+1,a+n+1);
    	for(int i=1;i<=n;i++)
    	{
    		for(int j=1;j<=i;j++)
    		{
    			s=a[i]-a[j];
    			if(s<=k)
    			{
    				s=0;
    				for(int k=j;k<=i;k++)
    				{
    					s+=a[k];
    				}
    				ma=max(ma,s);
    			}
    		}
    	}
    	cout<<ma;
    	return 0;
    }
    
    • 0
      @ 2025-6-14 13:48:49
      #include<bits/stdc++.h>
      using namespace std;
      const int N=15;
      char g[N][N];
      int main()
      {
      	int n,m;
      	cin>>n>>m;
      	for(int i=1;i<=n;i++)
      	{
      		for(int j=1;j<=m;j++)
      		{
      			cin>>g[i][j];	
      		} 
      	}
      	int res=0;
      	for(int x=1;x<=n;x++)
      	{
      		for(int y=1;y<=m;y++)
      		{
      			
      			for(int l=x;l<=n;l++)
      			{
      				for(int r=y;r<=m;r++)
      				{
      					int a=0,b=0;
      					for(int x1=x;x1<=l;x1++)
      					{
      						for(int y1=y;y1<=r;y1++)
      						{
      							if(g[x1][y1]=='0') a++;
      							else b++;
      						}
      					}
      					if(a==b)
      					{
      						res=max(res,(l-x+1)*(r-y+1));
      					}
      				}
      			}
      		}
      	}
      	cout<<res;
      	return 0;
      }
      
      
      • 1

      Information

      ID
      2183
      Time
      1000ms
      Memory
      256MiB
      Difficulty
      7
      Tags
      # Submissions
      21
      Accepted
      7
      Uploaded By