题目代码到是不难但是很难想通题目的解决方法。

#include<iostream>
using namespace std;
int person[];
int main()
{
int n,m;
while(cin>>n>>m)
{
memset(person,,sizeof(person));
int a,b,c;
for(int i=;i<m;i++)
{
cin>>a>>b>>c;
person[a]-=c;
person[b]+=c;
}
int ret = ;
for(int i=;i<=n;i++)
{
if(person[i]>=)
ret+=person[i];
}
cout<<ret<<endl;
} return ;
}

这就是A 欠 B 5,则arr[A]-=5;arr[b]+=5;最后把整数加起来就可以了。

codeforces 367B的更多相关文章

  1. python爬虫学习(5) —— 扒一下codeforces题面

    上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...

  2. 【Codeforces 738D】Sea Battle(贪心)

    http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...

  3. 【Codeforces 738C】Road to Cinema

    http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...

  4. 【Codeforces 738A】Interview with Oleg

    http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...

  5. CodeForces - 662A Gambling Nim

    http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...

  6. CodeForces - 274B Zero Tree

    http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...

  7. CodeForces - 261B Maxim and Restaurant

    http://codeforces.com/problemset/problem/261/B 题目大意:给定n个数a1-an(n<=50,ai<=50),随机打乱后,记Si=a1+a2+a ...

  8. CodeForces - 696B Puzzles

    http://codeforces.com/problemset/problem/696/B 题目大意: 这是一颗有n个点的树,你从根开始游走,每当你第一次到达一个点时,把这个点的权记为(你已经到过不 ...

  9. CodeForces - 148D Bag of mice

    http://codeforces.com/problemset/problem/148/D 题目大意: 原来袋子里有w只白鼠和b只黑鼠 龙和王妃轮流从袋子里抓老鼠.谁先抓到白色老鼠谁就赢. 王妃每次 ...

随机推荐

  1. in型子查询陷阱,exists子查询

    in 型子查询引出的陷阱 select goods_id from goods where cat_id in (1,2,3) 直接用id,不包含子查询,不会中陷阱 题: 在ecshop商城表中,查询 ...

  2. 剑指offer之 奇数偶数数组位置调整且保存顺序不变

    public class Solution { public void reOrderArray(int [] array) { reOrderCore(array,array.length); } ...

  3. 1.微信小程序-B站:前言准备

    前言 <微信小程序开发-B站>是以bilibili移动端网站为基础开发微信小程序版本,笔者喜欢的学习是愉快.轻松并能学到实战的东西,不知各位观友有没有一样的经历,就是一有问题不是先去Goo ...

  4. UOJ279 【UTR #2】题目交流通道

    本文版权归ljh2000和博客园共有,欢迎转载,但须保留此声明,并给出原文链接,谢谢合作. 本文作者:ljh2000  作者博客:http://www.cnblogs.com/ljh2000-jump ...

  5. Python快速学习-基础语法

  6. .net短信接口调用示例(106短信通道)

    1. [代码]调用代理示例 using System;using System.Data;using System.Configuration;using System.Collections;usi ...

  7. Codeforces 163A Substring and Subsequence:dp【子串与子序列匹配】

    题目链接:http://codeforces.com/problemset/problem/163/A 题意: 给你两个字符串a,b,问你有多少对"(a的子串,b的子序列)"可以匹 ...

  8. SSH三大框架的搭建整合(struts2+spring+hibernate)(转)

    原文地址:http://blog.csdn.net/kyle0349/article/details/51751913  尊重原创,请访问原文地址 SSH说的上是javaweb经典框架,不能说100% ...

  9. kettle文件以邮件附件的形式发送报告

    将从表中导出的excel文件以邮件附件的形式发送报告 step1: 导出文件file1.xls step2: add filename to result将文件添加到结果 step3: 发送邮件

  10. Struts2 - 文件的上传和下载

    1.  前言 这个章节是Struts2框架应用最广泛的三个版块(上传下载.国际化.校验输入)之一,所以这一版块的学习还蛮重要的. 2.  具体内容 回到顶部 2.1Struts2文件上传 2.1.1单 ...