#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的更多相关文章

  1. 1199 Problem B: 大小关系

    求有限集传递闭包的 Floyd Warshall 算法(矩阵实现) 其实就三重循环.zzuoj 1199 题 链接 http://acm.zzu.edu.cn:8000/problem.php?id= ...

  2. 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 ...

  3. C - NP-Hard Problem(二分图判定-染色法)

    C - NP-Hard Problem Crawling in process... Crawling failed Time Limit:2000MS     Memory Limit:262144 ...

  4. Time Consume Problem

    I joined the NodeJS online Course three weeks ago, but now I'm late about 2 weeks. I pay the codesch ...

  5. Programming Contest Problem Types

        Programming Contest Problem Types Hal Burch conducted an analysis over spring break of 1999 and ...

  6. hdu1032 Train Problem II (卡特兰数)

    题意: 给你一个数n,表示有n辆火车,编号从1到n,入站,问你有多少种出站的可能.    (题于文末) 知识点: ps:百度百科的卡特兰数讲的不错,注意看其参考的博客. 卡特兰数(Catalan):前 ...

  7. BZOJ2301: [HAOI2011]Problem b[莫比乌斯反演 容斥原理]【学习笔记】

    2301: [HAOI2011]Problem b Time Limit: 50 Sec  Memory Limit: 256 MBSubmit: 4032  Solved: 1817[Submit] ...

  8. [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 ...

  9. [LeetCode] The Skyline Problem 天际线问题

    A city's skyline is the outer contour of the silhouette formed by all the buildings in that city whe ...

  10. PHP curl报错“Problem (2) in the Chunked-Encoded data”解决方案

    $s = curl_init(); curl_setopt($s, CURLOPT_POST, true); curl_setopt($s, CURLOPT_POSTFIELDS, $queryStr ...

随机推荐

  1. k8s系列----索引

    day1:k8s集群准备搭建和相关介绍 day2:k8spod介绍与创建 day3:k8sService介绍及创建 day4:ingress资源和ingress-controller day5:存储卷 ...

  2. 网络设备 密码、用户级别 AAA授权 的管理

    一.进入 特权模式 密码 设置访问网络设备特权模式口令 cisco>enable cisco#config terminal cisco(config)#enable password 密码 e ...

  3. CDN&对象存储

    概念 CDN是什么:名词解释不清,加快静态资源访问的技术 CDN原理:将静态资源缓存到用户所在城市 实现 步骤1:注册七牛云账号 https://portal.qiniu.com/signup?cod ...

  4. Linux运维--11.手动部署Galera Cluster

    1.搭建galera集群 yum install epel-release yum install centos-release-openstack-stein #1.1 安装mariadb yum ...

  5. 分享8个laravel模型时间戳使用技巧

    默认情况下,Laravel Eloquent 模型默认数据表有 created_at 和 updated_at 两个字段.当 然,我们可以做很多自定义配置,实现很多有趣的功能.下面举例说明. 1. 禁 ...

  6. redis_入门

    Redis_day01 1. NoSql 1.1 NoSql是什么 NoSQL(不仅仅是SQL not only SQL),泛指非关系型的数据库.随着互联网web2.0网站的兴起,传统的关系数据库在处 ...

  7. SRAM结构框图解

    SRAM 即静态RAM.它也由晶体管组成,SRAM的高速和静态特性使它们通常被用来作为Cache存储器.计算机的主板上都有Cache插座. 下图所示的是一个SRAM的结构框图. 由上图看出SRAM一般 ...

  8. DAG求最短路--TSP变形--状压dp

    DAG状压dp的一种 题目: $m$个城市,$n$张车票,第i张车票上的时间是$t_i$, 求从$a$到$b$的最短时间,如果无法到达则输出“impossible” 解法: 考虑状态:“现在在城市$v ...

  9. Java软件工程师技能图谱

    原文链接:Java软件工程师技能图谱 最近在考虑"拥有怎样的技能才能算一名合格的java软件工程师呢?"这个问题.碰巧在github发现一个很棒的开源项目--程序员技能图谱.@Zh ...

  10. 记录zabbix4.0升级4.2

    系统环境 [root@localhost ~]# cat /etc/redhat-release CentOS release 6.9 (Final) 官方网站       官方文档升级其实很简单如果 ...