uva 538 - Balancing Bank Accounts(贪心)
来源:互联网 发布:vb程序设计视频教程 编辑:程序博客网 时间:2024/06/07 16:03
题目连接:uva 538 - Balancing Bank Accounts
处理每个人最后的钱,和最后一个人交易即可。
#include <cstdio>#include <cstring>#include <map>#include <string>#include <algorithm>using namespace std;const int maxn = 105;int N, M;map<string, int> G;int V[maxn], W;char name[maxn][maxn], s[maxn], t[maxn];int main () {int cas = 1;while (scanf("%d%d", &N, &M) == 2 && N + M) {G.clear();memset(V, 0, sizeof(V));for (int i = 1; i <= N; i++) {scanf("%s", name[i]);G[name[i]] = i;}for (int i = 0; i < M; i++) {scanf("%s%s%d", s, t, &W);V[G[s]] -= W, V[G[t]] += W;}printf("Case #%d\n", cas++);for (int i = 1; i < N; i++) {if (V[i] < 0)printf("%s %s %d\n", name[N], name[i], -V[i]);elseprintf("%s %s %d\n", name[i], name[N], V[i]);V[N] -= V[i];}printf("\n");}return 0;}
0 0
- uva 538 - Balancing Bank Accounts(贪心)
- UVA 538 - Balancing Bank Accounts(贪心)
- UVA 538 - Balancing Bank Accounts
- UVa538 - Balancing Bank Accounts
- UVA 12904 Load Balancing (暴力)
- R12 TCA BANKS, BRANCHES and Bank Accounts
- codeforces-796C-Bank Hacking(贪心)
- Codeforces Educational Codeforces Round 3 C. Load Balancing(贪心)
- uva 1381 - Balancing the Scale(枚举+位运算)
- HDU-2850-Load Balancing(贪心)
- hdu2850Load Balancing 贪心+优先队列
- uva 11389(贪心)
- uva - 10037(贪心)
- uva live3266(贪心)
- UVA 11636 (贪心)
- Hdu 2850 Load Balancing (贪心 优先队列)
- 【练习12】 贪心算法 1004 Load Balancing
- hdu 2850 Load Balancing (优先队列 + 贪心)
- 使用fragment argument
- uva 534 - Frogger(最小生成树)
- Android UI之ScrollView
- POJ 1002 487-3279
- Android UI之DrawerLayout
- uva 538 - Balancing Bank Accounts(贪心)
- The type javax.http.HttpServletRequest cannot be resolved.It is indirectly
- hdu 2544 最短路(floyd)
- 《机器学习实战》学习笔记:决策树的实现
- 一些容易忽略的知识
- Java设计模式--Java设计模式介绍
- proc中各种与进程相关的信息
- MFC利用正则表达式进行密码匹配
- string类的实现