Art Union
A well-known art union called "Kalevich is Alive!" manufactures objects d'art (pictures). The union consists of n painters who decided to organize their work as follows.
Each painter uses only the color that was assigned to him. The colors are distinct for all painters. Let's assume that the first painter uses color 1, the second one uses color 2, and so on. Each picture will contain all these n colors. Adding the j-th color to the i-th picture takes the j-th painter tij units of time.
Order is important everywhere, so the painters' work is ordered by the following rules:
- Each picture is first painted by the first painter, then by the second one, and so on. That is, after the j-th painter finishes working on the picture, it must go to the (j + 1)-th painter (if j < n);
- each painter works on the pictures in some order: first, he paints the first picture, then he paints the second picture and so on;
- each painter can simultaneously work on at most one picture. However, the painters don't need any time to have a rest;
- as soon as the j-th painter finishes his part of working on the picture, the picture immediately becomes available to the next painter.
Given that the painters start working at time 0, find for each picture the time when it is ready for sale.
The first line of the input contains integers m, n (1 ≤ m ≤ 50000, 1 ≤ n ≤ 5), where m is the number of pictures and n is the number of painters. Then follow the descriptions of the pictures, one per line. Each line contains n integers ti1, ti2, ..., tin (1 ≤ tij ≤ 1000), where tij is the time the j-th painter needs to work on the i-th picture.
Print the sequence of m integers r1, r2, ..., rm, where ri is the moment when the n-th painter stopped working on the i-th picture.
5 1
1
2
3
4
5
1 3 6 10 15
4 2
2 5
3 1
5 3
10 1
7 8 13 21
做题像是憋屎,想明白后,一下就出来了。
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <numeric>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <xfunctional>
#define ll long long
#define mod 998244353
using namespace std;
int dir[][] = { {,},{,-},{-,},{,} };
const int maxn = ;
const long long inf = 0x7f7f7f7f7f7f7f7f; int main()
{
int m, n;
cin >> m >> n;
vector<vector<int>> t(m+, vector<int>(n+,));
for (int i = ; i <= m; i++)
for (int j = ; j <= n; j++)
cin >> t[i][j];
for (int i = ; i <= m; i++)
{
for (int j = ; j <= n; j++)
{
if (t[i][j - ] < t[i - ][j])
t[i][j] += t[i - ][j];
else
t[i][j] += t[i][j - ];
}
}
for (int i = ; i <= m; i++)
{
cout << t[i][n] << " ";
}
return ;
}
Art Union的更多相关文章
- Codeforces Round #241 (Div. 2)->B. Art Union
B. Art Union time limit per test 1 second memory limit per test 256 megabytes input standard input o ...
- Codeforces Round #241 (Div. 2) B. Art Union 基础dp
B. Art Union time limit per test 1 second memory limit per test 256 megabytes input standard input o ...
- Codeforces Round #241 (Div. 2) B. Art Union (DP)
题意:有\(n\)个画家,\(m\)幅画,每个画家负责\(m\)幅画,只有前一个画家画完时,后面一个画家才能接着画,一个画家画完某幅画的任务后,可以开始画下一幅画的任务,问每幅画最后一个任务完成时的时 ...
- n个人作m幅画
题目网址: http://codeforces.com/problemset/problem/416/B A well-known art union called "Kalevich is ...
- Codeforces Round #241 (Div. 2) B dp
B. Art Union time limit per test 1 second memory limit per test 256 megabytes input standard input o ...
- The Art of Deception
前言 一些黑客毁坏别人的文件甚至整个硬盘,他们被称为电脑狂人(crackers)或计算机破坏者(vandals).另一些新手省去学习技术的麻烦,直接下载黑客工具侵入别人的计算机,这些人被称为脚本小子( ...
- Android内存优化(一)DVM和ART原理初探
相关文章 Android内存优化系列 Java虚拟机系列 前言 要学习Android的内存优化,首先要了解Java虚拟机,此前我用了多篇文章来介绍Java虚拟机的知识,就是为了这个系列做铺垫.在And ...
- SQL Server-聚焦UNIOL ALL/UNION查询(二十三)
前言 本节我们来看看有关查询中UNION和UNION ALL的问题,简短的内容,深入的理解,Always to review the basics. 初探UNION和UNION ALL 首先我们过一遍 ...
- SQL 提示介绍 hash/merge/concat union
查询提示一直是个很有争议的东西,因为他影响了sql server 自己选择执行计划.很多人在问是否应该使用查询提示的时候一般会被告知慎用或不要使用...但是个人认为善用提示在不修改语句的条件下,是常用 ...
随机推荐
- [CF1311C] Perform the Combo
Solution 前缀和搞一下即可 #include <bits/stdc++.h> using namespace std; #define int long long const in ...
- 基于axios的万能封装
一 . 命名axios.js import axios from 'axios'; export default function ajax(url = '', params = {}, type = ...
- Python 类 初学者笔记
面对象编程:编写表现世界中的事物和景象的类,并基于这些类创建对象,被创建的对象称为实例化. 创建类 class Dog(): #Python中类名称中的首字母要大写 def __init__(self ...
- 数组工具Array的基本使用
/* * Arrays数组工具的基本使用 */import java.util.Arrays; public class Day02_03 { public static void main(S ...
- 20200228 尚硅谷-NIO
尚硅谷-NIO Java NIO简介 Java NIO(New IO.Non Blocking IO)是从Java1.4版本开始引入的新的 IO API,可以替代标准的 Java IO API. NI ...
- js磁力线代码(非压缩,自己在压缩的版本上优化了代码,易于阅读)
拿去白嫖吧: <!DOCTYPE html> <html lang="zh-cn"> <head> <meta charset=" ...
- 网络共享服务(三)之SAMBA
前面说到了FTP和NFS,由于FTP是客户端和服务器基于ftp应用协议进行交换数据的,它不支持挂载共享目录的方式,而NFS又不支持跨平台,所以就催生了第三种网络共享服务:samba Samba是在Li ...
- Laravel框架中通过EasyWeChat发送公众号模板消息
环境要求 PHP >= 7.0 PHP cURL 扩展 PHP OpenSSL 扩展 PHP SimpleXML 扩展 PHP fileinfo 拓展 使用composer安装: $ compo ...
- mybatis及其与hibernate的对比
1.mybatis是支持普通SQL查询.存储过程.和高级映射的优秀持久层框架 它消除了JDBC代码和参数的手工设置,以及对结果集的检索 2.mybatis使用简单的XML或注解用于配置和原始映射,将接 ...
- Docker最全教程——从理论到实战(十七)
前言 上一篇我们通过实战分享了使用Go推送钉钉消息,由于技痒,笔者现在也编写了一个.NET Core的Demo,作为简单的对照和说明. 最后,由于精力有限,笔者希望有兴趣的朋友可以分享下使用CoreR ...