• <input id="auww4"></input>
  • <input id="auww4"><acronym id="auww4"></acronym></input>
  • <input id="auww4"><u id="auww4"></u></input>
    <object id="auww4"><acronym id="auww4"></acronym></object>
    <menu id="auww4"></menu><input id="auww4"><u id="auww4"></u></input>
    <input id="auww4"><u id="auww4"></u></input>
  • F.A.Q
    Hand In Hand
    Online Acmers
    Forum | Discuss
    Statistical Charts
    Problem Archive
    Realtime Judge Status
    Authors Ranklist
     
         C/C++/Java Exams     
    ACM Steps
    Go to Job
    Contest LiveCast
    ICPC@China
    Best Coder beta
    VIP | STD Contests
    Virtual Contests
        DIY | Web-DIY beta
    Recent Contests
    Author ID 
    Password 
     Register new ID

    wa求指點,試過多組數據仍找不到原因 orz

    Posted by iOzzulyz at 2020-10-07 13:47:32
    (0)  


    #include<iostream>
    #include<cmath>
    #include<cstring>
    #include<algorithm>
    using namespace std;
    int main()
    {
    	int m;
    	int num[501],dp[501];
    	cin>>m;
    	while(m--)
    	{
    		int n;
    		cin>>n;
    		int Min=10000;
    		memset(num,0,501);
    	    memset(dp,0,501);
    		for(int i=0;i<n;i++)
    		{
    			cin>>num[i];
    		}
    		for(int i=0;i<n;i++)
    		{
    			for(int j=0;j<n;j++)
    			{
    				dp[i]=dp[i]+abs(num[i]-num[j]);
    			}
    		}
    		for(int i=0;i<n;i++)
    		{
    			if(Min>dp[i])
    			{
    				Min=dp[i];
    			}
    		}
    		cout<<Min<<endl;
    	}
    }

    Followed by:


    Post your reply here:

    Author ID
    Password
    Title
    Content  
     
    Hangzhou Dianzi University Online Judge 3.0
    Copyright © 2005-2020 HDU ACM Team. All Rights Reserved.
    Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
    Total 0.015600(s) query 5, Server time : 2020-10-11 19:10:43, Gzip enabled
    棋牌