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

O(M*N),供大家鄙视,不用排序

Posted by Eclipse2008 at 2011-09-06 21:17:02 on Problem 1323 and last updated at 2011-09-06 21:20:16
题目就是问
在最坏的情况下能赢多少次,最坏的情况就是每次有一个人出了一个比自己出的牌大1的牌,按照这样考虑

直接把手中有的牌记录在一个数组visit中,visit[i]== true 表示有i这张牌
记录一个num,初始为0
 
for(i = m*n;i >= 1;i --)
   如果这张牌手中没有,num ++ 
   如果这张牌手中有
     如果num == 0,ans ++;
     否则num -- ;

最后的ans就是结果,           

注意数组visit要大,开50会WA

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