问题 E: Problem B
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
int n;
while (scanf("%d", &n) != EOF) {
int rsum[n];
int csum[n];
int sum1 = 0;
int sum2 = 0;
memset(rsum, 0, sizeof(rsum));
memset(csum, 0, sizeof(csum));
//input
for (int i = 0; i < n; ++i) {
for (int j = 0; j < n; ++j) {
int temp;
scanf("%d", &temp);
if (i == j) sum1 += temp;
if (i + j == n - 1) sum2 += temp;
rsum[j] += temp;
csum[i] += temp;
}
}
vector<int> ans;
ans.push_back(sum1);
ans.push_back(sum2);
for (int k = 0; k < n; ++k) {
ans.push_back(rsum[k]);
ans.push_back(csum[k]);
}
sort(ans.begin(), ans.end(), [](const int &a, const int &b) {
return a - b > 0;
});
int x = ans.size();
for (int i = 0; i < x; i++) {
printf("%d", ans[i]);
if (i != x - 1) printf(" ");
}
printf("\n");
}
return 0;
}
问题 E: Problem B的更多相关文章
- 1199 Problem B: 大小关系
求有限集传递闭包的 Floyd Warshall 算法(矩阵实现) 其实就三重循环.zzuoj 1199 题 链接 http://acm.zzu.edu.cn:8000/problem.php?id= ...
- No-args constructor for class X does not exist. Register an InstanceCreator with Gson for this type to fix this problem.
Gson解析JSON字符串时出现了下面的错误: No-args constructor for class X does not exist. Register an InstanceCreator ...
- C - NP-Hard Problem(二分图判定-染色法)
C - NP-Hard Problem Crawling in process... Crawling failed Time Limit:2000MS Memory Limit:262144 ...
- Time Consume Problem
I joined the NodeJS online Course three weeks ago, but now I'm late about 2 weeks. I pay the codesch ...
- Programming Contest Problem Types
Programming Contest Problem Types Hal Burch conducted an analysis over spring break of 1999 and ...
- hdu1032 Train Problem II (卡特兰数)
题意: 给你一个数n,表示有n辆火车,编号从1到n,入站,问你有多少种出站的可能. (题于文末) 知识点: ps:百度百科的卡特兰数讲的不错,注意看其参考的博客. 卡特兰数(Catalan):前 ...
- BZOJ2301: [HAOI2011]Problem b[莫比乌斯反演 容斥原理]【学习笔记】
2301: [HAOI2011]Problem b Time Limit: 50 Sec Memory Limit: 256 MBSubmit: 4032 Solved: 1817[Submit] ...
- [LeetCode] Water and Jug Problem 水罐问题
You are given two jugs with capacities x and y litres. There is an infinite amount of water supply a ...
- [LeetCode] The Skyline Problem 天际线问题
A city's skyline is the outer contour of the silhouette formed by all the buildings in that city whe ...
- PHP curl报错“Problem (2) in the Chunked-Encoded data”解决方案
$s = curl_init(); curl_setopt($s, CURLOPT_POST, true); curl_setopt($s, CURLOPT_POSTFIELDS, $queryStr ...
随机推荐
- 深入了解MySQL,一篇简短的总结
MySQL的基本语法 这里作为MySQL部分模块的深入了解,大部分都是理论方面的笔记,不会写具体用法. 具体用法会记录在下面这个随笔分类下,不过暂时还没更新完,等过段时间会更新下事务.存储过程.索引等 ...
- Thread类的interrupted方法和isInterrupted方法的区别
如下所示,interrupted()会改变线程的中断状态(清除),而isInterrupted()不影响线程的中断状态 /** * Tests whether the current thread ...
- Windows下无法颜色转义
只需在最前面添加 import os os.system("") 参考文献:https://blog.csdn.net/ytzlln/article/details/8194524 ...
- ubuntu 配置网卡,DNS, iptables
# 配置静态ip地址 root@simon:~# vim /etc/network/interfaces auto enp4s0 iface enp4s0 inet static address 19 ...
- 【全集】IDEA入门到实战
课程介绍 IDEA是一款功能强悍.非常好用的Java开发工具,近几年编程开发人员对IDEA情有独钟.虽然IDEA功能很强大,但目前市面讲解的不细致.不系统,导致很多IDEA初学者要么无从下手,要么 ...
- MD5加密常用js库:crypto-js
学习链接:https://github.com/brix/crypto-js
- F——宋飞正传(HDU3351)
题目: I’m out of stories. For years I’ve been writing stories, some rather silly, just to make simpl ...
- Task.Run()方法总结
一.从异步方法的声明说起 无返回值的类型异步方法 (1)public async Task MethodName() 带返回值类型的异步方法 (2)public async Task<TResu ...
- Python学习小记(4)---class
1.名称修改机制 大概是会对形如 __parm 的成员修改为 _classname__spam 9.6. Private Variables “Private” instance variables ...
- 《ASP.NET Core应用开发入门教程》与《ASP.NET Core 应用开发项目实战》正式出版
“全书之写印,实系初稿.有时公私琐务猬集,每写一句,三搁其笔:有时兴会淋漓,走笔疾书,絮絮不休:有时意趣萧索,执笔木坐,草草而止.每写一段,自助覆阅,辄摇其首,觉有大不妥者,即贴补重书,故剪刀浆糊乃不 ...