编程介的小学生 2016-11-13 03:43 采纳率: 20.5%
浏览 1033
已采纳

Jack's struggle

Description
A team of airborne troops are ready to complete some missions.
The battlefield was divided into a grid of n*n, this team can be air-dropped at any place on time 0. In every time unit after landing, they can go to the grid left, right, up or down to the current grid, or they can just stay.
On their mission list, each mission is described as three integers: t, r and c, represents a task that must be completed exactly at time t on the grid (r, c).
Obviously, with limits of time, not all missions can be done.
The captain, Jack, struggling making decisions, wants to know how many missions they can complete at most.

Input
The input contains serveral cases:

For each case:

  • The first line contains two integers n and m, 1<=n<=1000, 1<=m<=10000, n represents the size of the battlefield and m represents the number of missions on the list.

  • Following m lines, each one describes a mission using three integers, t, r and c.

No two missions have the same t, r and c.

The input is terminated by n=m=0.

Output
One integer in one line represents the maximum number of mission that can be completed.

Sample Input
2 2 1 1 1 2 2 2 0 0

Sample Output
1

  • 写回答

2条回答 默认 最新

  • threenewbee 2016-11-13 05:22
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥20 matlab yalmip kkt 双层优化问题
  • ¥15 如何在3D高斯飞溅的渲染的场景中获得一个可控的旋转物体
  • ¥88 实在没有想法,需要个思路
  • ¥15 MATLAB报错输入参数太多
  • ¥15 python中合并修改日期相同的CSV文件并按照修改日期的名字命名文件
  • ¥15 有赏,i卡绘世画不出
  • ¥15 如何用stata画出文献中常见的安慰剂检验图
  • ¥15 c语言链表结构体数据插入
  • ¥40 使用MATLAB解答线性代数问题