#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. 《Head first设计模式》之抽象工厂

    抽象工厂模式提供一个接口,用于创建相关或依赖对象的家族,而不需要明确指定具体类. 确保原料的一致 披萨店成功的关键在于新鲜.高质量的原料.要如何确保每家加盟店使用高质量的原料?你打算建造一家生成原料的 ...

  2. qt creator源码全方面分析(2-5)

    目录 Creating Wizards in Code 介绍 相关类 IWizardFactory的设置器和获取器 Creating Wizards in Code 介绍 如果基于模板的自定义向导提供 ...

  3. Linux相关知识笔记

    Quagga要在linux下编译并配置运行,所有,学习一点linux的基础知识. 安装的Ubuntu,用户名linux,密码1 使能Ubuntu的IP转发功能,需要修改etc/sysctl.conf和 ...

  4. Java自学-多线程 线程安全的类

    Java常见的线程安全相关的面试题 步骤 1 : HashMap和Hashtable的区别 HashMap和Hashtable都实现了Map接口,都是键值对保存数据的方式 区别1: HashMap可以 ...

  5. 分布式系统的CAP定理

    CAP定理: 在一个分布式系统中,Consistency(数据一致性). Availability(服务可用性).Partition tolerance(分区容错性),三者不可兼得. 一致性(Cons ...

  6. GMOJ5409.【GDOI2017模拟一试4.11】平行宇宙

    https://gmoj.net/senior/#main/show/5051 Solution 首先注意到每个点有且只有一条出边,也就是说这是一个环套树(森林). 那么我们可以贪心. 首先这个森林里 ...

  7. idea如何做到多模块开发项目 收藏整理

    idea如何做到多模块开发项目 <packaging>pom</packaging>是什么意思? idea 快捷键汇总

  8. Dijkstra算法 1

    // Dijkstra算法,适用于没有负边的情况 // 注意:是没有负边,不是没有负环 // 在这一条件下,可以将算法进行优化 // 从O(v*E)的复杂度,到O(V^2)或者是O(E*log(V)) ...

  9. Node.js文档-path

    用于处理文件路径和目录路径 引入 const path = require('path') path.extname(path) 返回扩展名.从最后一次出现 . 字符到字符串结束. const pat ...

  10. NODEJS 搭建本地文件服务器

    npm install anywhere --g 然后再任意目录位置运行 anywhere 80 就可以开启服务器.