| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
始终WA,能否帮看下原因?#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator