Codeforces Global Round 6D(VECTOR<ARRAY<INT,3> >)
一个人只要存在债务关系,那么他的债务可以和这整个债务关系网中任何人连边,和他当初借出或欠下的人没有关系。只需要记录他的债务值即可。
#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
long long val[];
vector<array<long long,> >v;
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
long long n;
cin>>n;
long long m;
cin>>m;
for(long long i=;i<=m;++i){
long long a,b,c;
cin>>a>>b>>c;
val[a]-=c;
val[b]+=c;
}
long long pos=;
for(long long i=;i<=n;++i){
while(val[i]>){
while(val[pos]>=)
++pos;
long long mn=min(-val[pos],val[i]);
val[i]-=mn;
val[pos]+=mn;
v.push_back({pos,i,mn});
}
}
cout<<v.size()<<"\n";
for(auto it:v)
cout<<it[]<<" "<<it[]<<" "<<it[]<<"\n";
return ;
}
Codeforces Global Round 6D(VECTOR<ARRAY<INT,3> >)的更多相关文章
- Codeforces Global Round 1D(DP,思维)
		
#include<bits/stdc++.h>using namespace std;int dp[1000007][7][7];int cnt[1000007];int main(){ ...
 - Codeforces Global Round 5E(构造,思维)
		
#define HAVE_STRUCT_TIMESPEC#include<bits/stdc++.h>using namespace std;int main(){ ios::sync_w ...
 - Codeforces Global Round 4E(字符串,思维)
		
#include<bits/stdc++.h>using namespace std;string s,a,b;int main(){ cin>>s; int n=s.size ...
 - Codeforces Global Round 1 (CF1110) (未完结,只有 A-F)
		
Codeforces Global Round 1 (CF1110) 继续补题.因为看见同学打了这场,而且涨分还不错,所以觉得这套题目可能会比较有意思. 因为下午要开学了,所以恐怕暂时不能把这套题目补 ...
 - Codeforces Global Round 11 个人题解(B题)
		
Codeforces Global Round 11 1427A. Avoiding Zero 题目链接:click here 待补 1427B. Chess Cheater 题目链接:click h ...
 - Codeforces Global Round 1 - D. Jongmah(动态规划)
		
Problem Codeforces Global Round 1 - D. Jongmah Time Limit: 3000 mSec Problem Description Input Out ...
 - Codeforces Global Round 3
		
Codeforces Global Round 3 A. Another One Bites The Dust 有若干个a,有若干个b,有若干个ab.你现在要把这些串拼成一个串,使得任意两个相邻的位置 ...
 - Codeforces Global Round 2 题解
		
Codeforces Global Round 2 题目链接:https://codeforces.com/contest/1119 A. Ilya and a Colorful Walk 题意: 给 ...
 - Codeforces Global Round 1 (A-E题解)
		
Codeforces Global Round 1 题目链接:https://codeforces.com/contest/1110 A. Parity 题意: 给出{ak},b,k,判断a1*b^( ...
 
随机推荐
- linux用户管理相关命令
			
查看用户以及用户组: cat /etc/group [root@izuf60kjjii4iwkhdsly3bz html]# cat /etc/group 内容具体分析 /etc/group ...
 - Wannafly Camp 2020 Day 7H 游戏 - 欧拉筛,GCD
			
忘记特判 \(1\) ,血了一地 听说 \(O(n^2 \log n)\) 能过? #include <bits/stdc++.h> #define int long long using ...
 - Unable to connect to Elasticsearch at http://elasticsearch:9200.  statu red   Kibana 安装
			
解决方案 docker run -d -p 5601:5601 --link elasticsearch -e "elasticsearch_url=容器ip:9200" --na ...
 - Eclipse创建JSP、HTML、CSS文件默认字符集设置成UTF-8
			
问题:在使用eclipse的时候总是发现新创建的JSP文件.HTML文件等默认总是ISO-8859-1,每次都要修改成自己使用的utf-8的,很是麻烦,因此在网上查看了一下发现是可以修改字符集的默认值 ...
 - day02_1spring3
			
面向切面编程.AOP手动代理和spring编写代理 一.什么是AOP 1.AOP简介: 在软件业,AOP为Aspect Oriented Programming的缩写,意为:面向切面编程,通过预编译方 ...
 - pytorch之max()函数
			
pytorch之max()函数 待办 返回对应给定中最大值的索引,方便进行和target结果的索引进行比较 索引方式见下 https://blog.csdn.net/liuweiyuxiang/art ...
 - dijkstra算法为什么不能处理带有负边权的图
			
1 2 3 1 0 8 9 2 10 0 10 3 10 -2 0 先看样例再解释,看邻接矩阵会发现, 如果用dijkstra算1-2的最短路因为贪心思想所以得到的结果是8,但明显可以看到1-3- ...
 - xshell连接本地虚拟机中的centos
			
1. 一开始Xshell连接不上(设置为DHCP 动态IP)虚拟机上的centos8 参考这篇博文,将centos上的DHCP改为static 静态IP xshell连接本地虚拟机中的centos 2 ...
 - 对json 数据的处理
			
今天一个任务是,从一个指定接口中获取 json 字符串,并将其中指定的数据,以列表的形式表示出来. 唯一注意:json 字符串,需要先转换成 json 对象. var json对象= eval('( ...
 - Java中new一个子类对象的同时并不会自动创建一个父类对象
			
首先重申一个概念:子类会继承父类所有非私有成员变量和方法,包括父类的构造方法 当创建一个子类对象时,首先开辟内存,然后调用类的构造函数,这里的构造函数由两部分组成,一部分是从父类继承而来的父类的构造方 ...