Gym - 101147H H. Commandos DAG
来源:互联网 发布:利驰软件怎么样 编辑:程序博客网 时间:2024/06/05 00:37
H - 记忆里在微甜
Gym - 101147HStatements
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[k][i][j] = max(dp[k][i][j], dp[k][i][j+1] + mp[k][i][j]);
dp[k][i][j] = max(dp[k][i][j], dp[k-1][i][j] + mp[k][i][j]);
#include <iostream>#include <cstdio>#include <cstring>using namespace std;typedef long long LL;const int maxn = 1e6 + 8;int dp[12][12][12], mp[12][12][12];int main(){ freopen("commandos.in", "r", stdin); #ifdef LOCAL freopen("h.txt", "r", stdin); //freopen("h.out", "w", stdout); #endif // LOCAL ios::sync_with_stdio(false); cin.tie(0); int T, n, f, y, x, i, j, k; cin >> T; while(T--){ memset(dp, 0, sizeof dp); memset(mp, 0, sizeof mp); cin >> n; for(i = 1; i <= n; i++){ cin >> f >> y >> x; cin >> mp[f][y][x]; } for(k = 1; k <= 10; k++){ for(i = 10; i >= 1; i--){ for(j = 10; j >= 1; j--){ dp[k][i][j] = max(dp[k][i][j], dp[k][i+1][j] + mp[k][i][j]); dp[k][i][j] = max(dp[k][i][j], dp[k][i][j+1] + mp[k][i][j]); dp[k][i][j] = max(dp[k][i][j], dp[k-1][i][j] + mp[k][i][j]); } } } cout << dp[10][1][1] << "\n"; } return 0;}
Thank you!
- Gym - 101147H H. Commandos DAG
- GYM 101147 H.Commandos(dp)
- Gym Commandos
- GYM 100523H
- codeforces GYM 100792H
- Gym 100712H Bridges
- Gym 100947H-Phobia
- Gym - 100735H
- Gym-101490H
- Gym 101164.H
- Gym 101246.H
- Gym 101482.H
- Gym 100825 H
- Gym 101201.H
- Gym 101617H
- Codeforces Gym 100623H Problem H. Holes
- Gym 100187H - Mysterious Photos
- Gym 100015H Hidden Code
- ARM体系结构(一)
- 【zabbix】利用LLD自动发现功能监控多Memcached实例
- 随笔
- 爬取微博用户的原创微博
- linux查看进程启动时间
- Gym - 101147H H. Commandos DAG
- spring rmi
- POJ 3218 文本对齐 中文
- 20170131 | 阅读 | 个人向
- Spring HtmlUtils把HTML编码转义,可将HTML标签互相转义
- 自定义View 篇三 《手动打造ViewPage》
- MySQL 笔记
- poj 3262 Protecting the Flowers
- POJ 3219 二项式系数 中文