Gym Commandos
来源:互联网 发布:网络信息收集方法 编辑:程序博客网 时间:2024/05/20 19:18
A commando is a soldier of an elite light infantry often specializing in amphibious landings, abseiling or parachuting. This time our Commando unit wants to free as many hostages as it could from a hotel in Byteland, This hotel contains 10 identical floors numbered from 1 to 10 each one is a suite of 10 by 10 symmetric square rooms, our unit can move from a room (F, Y, X) to the room right next to it (F, Y, X + 1) or front next to it (F, Y + 1, X) and it can also use the cooling system to move to the room underneath it (F - 1, Y, X).
Knowing that our unit parachuted successfully in room 1-1 in floor 10 with a map of hostages locations try to calculate the maximum possible hostages they could save.
Your program will be tested on one or more test cases. The first line of the input will be a single integer T. Followed by the test cases, each test case contains a number N (1 ≤ N ≤ 1, 000) representing the number of lines that follows. Each line contains 4 space separated integers (1 ≤ F, Y, X, H ≤ 10) means in the floor number F room Y-X there are H hostages.
For each test case, print on a single line, a single number representing the maximum possible hostages that they could save.
2310 5 5 110 5 9 510 9 5 931 5 5 15 5 9 55 9 5 8
108
简单的三维dp
#include <iostream>#include <cstdio>#include <cstring>#include <cmath>#include <algorithm>using namespace std;int s[15][15][15];int Max(int a, int b, int c){if(b > a)a = b;if(c > a)a = c;return a;}int main(){freopen("commandos.in","r",stdin);//freopen("standard output","w",stdout);int t, n;int f, y, x, h;cin>>t;while(t--){memset(s,0,sizeof(s));cin>>n;while(n--){cin>>f>>y>>x>>h;s[f][y][x] += h;}int i, j, k;for(i = 10;i > 0;i--){for(j = 1;j <= 10;j++){for(k = 1;k <= 10;k++){s[i][j][k] = s[i][j][k] + Max(s[i+1][j][k], s[i][j-1][k], s[i][j][k-1]);}}}cout<<s[1][10][10]<<endl;}return 0;}
- Gym Commandos
- Gym - 101147H H. Commandos DAG
- GYM 101147 H.Commandos(dp)
- Commandos
- commandos 系列
- Gym
- Gym
- Gym
- Gym
- Gym
- Gym
- Gym
- Gym
- Gym
- Gym
- Gym
- Gym
- Gym
- 支付宝小程序审核与发布
- Windows下Nginx的启动、停止等命令
- NPM 国内被墙的解决方法
- Android 技术的回顾第一篇《网络检测》
- 动态的修改td的内容
- Gym Commandos
- USB总线学习心得及资料
- highcharts 动态设置series
- php-cgi.exe系统错误 无法启动程序,因为计算机中丢失api-ms-win-crt-conio-l1-1-0.dll 尝试解决安装该程序以解决此问题
- Java开发中Tomcat中session的管理机制
- java将list转为树形结构的方法
- 运算
- validform入门
- C#的Enum——枚举