HZNU Training 3—H
来源:互联网 发布:淘宝网衣服女裤 编辑:程序博客网 时间:2024/05/18 08:34
H - Commandos
Statements
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
【代码】
#include <stdio.h>#include <string.h>#include <algorithm>using namespace std;int f[20][20][20];int a[20][20][20];int x,y,z,q,n,pp,X,Y,Z;int main(){FILE *p1;p1=fopen("commandos.in","r");fscanf(p1,"%d",&pp);while (pp--){memset(a,0,sizeof(a));memset(f,0,sizeof(f));fscanf(p1,"%d",&n);while (n--){fscanf(p1,"%d%d%d%d",&x,&y,&z,&q);a[x][y][z]+=q;}for (int i=10;i>=1;i--)for (int j=1;j<=10;j++)for (int k=1;k<=10;k++)f[i][j][k]=a[i][j][k]+max(max(f[i][j][k-1],f[i][j-1][k]),f[i+1][j][k]);printf("%d\n",f[1][10][10]);}return 0;}
- HZNU Training 3—H
- HZNU Training 3—E
- HZNU Training 3—L
- HZNU Training 3—M
- UESTC Training for Data Structures——H
- UESTC Training for Search Algorithm——H
- UESTC Training for Graph Theory——H、Redundant Paths
- SCUT Training 20170913 Problem H
- SCUT Training 20170920 Problem H
- 2014 UESTC Training for Search Algorithm H
- 2014 UESTC Training for Graph Theory H
- H - Load Balancing---(2015 NEUQ_ACM summer training #1)
- H - Hurdles of 110m----(2015 summer training #4 (Qualifying))
- H - Sum---(2015 summer training #12(Team_Qualifying))
- 2016 UESTC Training for Math(没有B H I)
- 2016 Personal Training #8 Div.2 A B H
- HZNU-1575 愚蠢的摄影师
- HZNU-能量项链【区间dp】
- json与string相互转化
- css居中小结
- android studio2.3更新下载gradle-3.3-all.zip失败
- Notice: Undefined variable
- Java面向对象(二)-三大特性
- HZNU Training 3—H
- 第一次记录自己学习中的问题(新手)----回调函数(复制别人的)
- [Spring]配置数据库读写分离
- 从身份证号提取出生日期
- SharedPreferences 的另一种场景的用法
- RSA 非对称加解密
- Android四大基本组件介绍及生命周期
- 积累
- QT4 支持C++11 与QT5的区别