Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

哪题都不知道……

Posted by 150014 at 2011-05-11 21:39:03
In Reply To:始终WA,能否帮看下原因? Posted by:smhan at 2011-05-11 21:26:34
> #include <iostream>
> #include <utility>
> #include <map>
> #include <algorithm>
> using namespace std;
> 
> int main()
> {
> 	int num;
> 	int iLineNum,iColNum;
> 	int iPickNum;
> 	int iTime,iCostTime;
> 	int iValue;
> 	map<int,pair<int,int>,greater<int>> iArray;
> 	map<int,pair<int,int>,greater<int>>::iterator pos,prepos;
> 	
> 	cin>>num;
> 	while (num-- >0)
> 	{
> 		cin>>iLineNum>>iColNum;
> 		cin>>iTime;
> 		for(int i = 1;i <= iLineNum;i++)
> 		{
> 			for(int j = 1;j <= iColNum;j++)
> 			{
> 				cin>>iValue;
> 				if(iValue != 0)
> 					iArray.insert(make_pair(iValue,make_pair(i,j)));
> 			}
> 		}
> 		prepos = iArray.begin();
> 		iPickNum = 0;
> 		iCostTime = 0;
> 		int a,b;
> 		for(pos = iArray.begin();pos != iArray.end();++pos){
> 			if(pos == iArray.begin())
> 			{
> 				a = pos->second.first+1;
> 				b = pos->second.first;
> 			}
> 			else
> 			{
> 				a = abs(pos->second.first-prepos->second.first)+
> 					abs(pos->second.second-prepos->second.second)+1;
> 				b = pos->second.first;
> 
> 			}
> 			if(iCostTime+a+b <= iTime)
> 			{
> 				iPickNum += pos->first;
> 				iCostTime += a;
> 			}
> 			else
> 				break;
> 			prepos = pos;
> 		}
> 		cout<<iPickNum<<endl;
> 	}
> 
> 	return 0;
> }

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator