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^( ...
随机推荐
- new Vue发生了什么(五)
从入口代码开始分析,我们先来分析 new Vue 背后发生了哪些事情.我们都知道,new 关键字在 Javascript 语言中代表实例化是一个对象,而 Vue 实际上是一个类,类在 Javascri ...
- java 学习(day2) 时钟类
看过python的面向对象,所以入手java总的来说还是比较快的. 看视频学习之后写了一个简单的时钟 一个时钟有两部分组成小时和分钟.再大一些还有月,日. 分析一下就是,上述这些属性到达一个值之后,就 ...
- ECMAScript基本语法——④变量
简介 变量:一小块存储数据的内存空间先申请了一块内存空间,规定空间的存储类型,给空间赋值3, 想找到这个3可以通过内存空间的地址值,但是通过地址值太麻烦了,给这个空间起了一个名字a 通过这个a可以找到 ...
- 143. 最大异或对(Trie树存整数+二进制)
在给定的N个整数A1,A2……ANA1,A2……AN中选出两个进行xor(异或)运算,得到的结果最大是多少? 输入格式 第一行输入一个整数N. 第二行输入N个整数A1A1-ANAN. 输出格式 输出一 ...
- C 库函数 - strcpy()
描述 C 库函数 char *strcpy(char *dest, const char *src) 把 src 所指向的字符串复制到 dest. 需要注意的是如果目标数组 dest 不够大,而源字符 ...
- 初步自学Java小结
本周学习Java使我印象最深刻的Java开发环境的安装与设置,通过下载Eclipse IDE for Java Developers初步搭建好了Java开发环境,之后利用视频了解了Java程序的类型及 ...
- Tomcat 加载外部dll时如何配置
1.在myeclipse环境下配置 先将dll放置在c:\windows\system32中,然后在myEclipse中,window->Preferences->MyEclipse-&g ...
- OERR: ORA-32004 "obsolete or deprecated parameter(s) specified for %s instance"
Oracle 11gR2通过Memory创建动态参数文件后,通过SPFILE启动,提示 ORA-32004: obsolete or deprecated parameter(s) specified ...
- 剑指offer 面试题. 剪绳子
题目描述 给你一根长度为n的绳子,请把绳子剪成整数长的m段(m.n都是整数,n>1并且m>1),每段绳子的长度记为k[0],k[1],...,k[m].请问k[0]xk[1]x...xk[ ...
- Git 添加远程github仓库的时候提示错误:fatal: remote origin already exists.
1.先删除远程 Git 仓库 $ git remote rm origin 2.再添加远程 Git 仓库 $ git remote add origin git@github.com:wsydxian ...