当前位置: 首页 > news >正文

蓬莱建设局规划处网站好的营销网站

蓬莱建设局规划处网站,好的营销网站,wordpress下载的主题怎么安装,全球最大的网站建设外包网✅作者简介:人工智能专业本科在读,喜欢计算机与编程,写博客记录自己的学习历程。 🍎个人主页:小嗷犬的个人主页 🍊个人网站:小嗷犬的技术小站 🥭个人信条:为天地立心&…

✅作者简介:人工智能专业本科在读,喜欢计算机与编程,写博客记录自己的学习历程。
🍎个人主页:小嗷犬的个人主页
🍊个人网站:小嗷犬的技术小站
🥭个人信条:为天地立心,为生民立命,为往圣继绝学,为万世开太平。


本文目录

    • Title
      • Time Limit
      • Memory Limit
      • Problem Description
      • Input
      • Output
      • Sample Input
      • Sample Onput
      • Note
      • Source
    • Solution


Title

CodeForces 1804 D. Accommodation

Time Limit

2 seconds

Memory Limit

512 megabytes

Problem Description

Annie is an amateur photographer. She likes to take pictures of giant residential buildings at night. She just took a picture of a huge rectangular building that can be seen as a table of n×mn \times mn×m windows. That means that the building has nnn floors and each floor has exactly mmm windows. Each window is either dark or bright, meaning there is light turned on in the room behind it.

Annies knows that each apartment in this building is either one-bedroom or two-bedroom. Each one-bedroom apartment has exactly one window representing it on the picture, and each two-bedroom apartment has exactly two consecutive windows on the same floor. Moreover, the value of mmm is guaranteed to be divisible by 444 and it is known that each floor has exactly m4\frac{m}{4}4m two-bedroom apartments and exactly m2\frac{m}{2}2m one-bedroom apartments. The actual layout of apartments is unknown and can be different for each floor.

Annie considers an apartment to be occupied if at least one of its windows is bright. She now wonders, what are the minimum and maximum possible number of occupied apartments if judged by the given picture?

Formally, for each of the floors, she comes up with some particular apartments layout with exactly m4\frac{m}{4}4m two-bedroom apartments (two consecutive windows) and m2\frac{m}{2}2m one-bedroom apartments (single window). She then counts the total number of apartments that have at least one bright window. What is the minimum and maximum possible number she can get?

Input

The first line of the input contains two positive integers nnn and mmm (1≤n⋅m≤5⋅1051 \leq n \cdot m \leq 5 \cdot 10^51nm5105) — the number of floors in the building and the number of windows per floor, respectively. It is guaranteed that mmm is divisible by 444.

Then follow nnn lines containing mmm characters each. The jjj-th character of the iii-th line is “0” if the jjj-th window on the iii-th floor is dark, and is “1” if this window is bright.

Output

Print two integers, the minimum possible number of occupied apartments and the maximum possible number of occupied apartments, assuming each floor can have an individual layout of m4\frac{m}{4}4m two-bedroom and m2\frac{m}{2}2m one-bedroom apartments.

Sample Input

5 4
0100
1100
0110
1010
1011

Sample Onput

7 10

Note

In the first example, each floor consists of one two-bedroom apartment and two one-bedroom apartments.

The following apartment layout achieves the minimum possible number of occupied apartments equal to 777.

|0 1|0|0|
|1 1|0|0|
|0|1 1|0|
|1|0 1|0|
|1|0|1 1|

The following apartment layout achieves the maximum possible number of occupied apartments equal to 101010.

|0 1|0|0|
|1|1 0|0|
|0 1|1|0|
|1|0 1|0|
|1 0|1|1|

Source

CodeForces 1804 D. Accommodation


Solution

n, m = map(int, input().split())
smin = smax = 0for i in range(n):s = input()two = j = 0# 将连续两盏灯都先视为两居室while j < m - 1:if s[j] == '1' and s[j + 1] == '1':j += 1two += 1j += 1two = min(two, m // 4)  # 两居室的数量不能超过总窗户数的四分之一smin += s.count('1') - twotwo = j = 0# 统计可能的不开灯的两居室和只开一盏灯的两居室数量while j < m - 1:if s[j] != '1' or s[j + 1] != '1':j += 1two += 1j += 1two = min(two, m // 4)  # 两居室的数量不能超过总窗户数的四分之一smax += s.count('1') - (m // 4 - two)  # (m // 4 - two) 为开两盏灯的两居室数量
print(smin, smax)
http://www.yidumall.com/news/3457.html

相关文章:

  • 如何申请企业邮箱帐号网站优化公司排名
  • 网站策划与建设阶段的推广重庆百度seo整站优化
  • 上海到北京高铁几小时seo短视频入口引流
  • 服务器网站部署百度网盘下载
  • 做网站运营的要求国际形势最新消息
  • ui自学网站seo权威入门教程
  • 营销型网站制作无锡网站关键词推广
  • 可做用户密码暴力破解测试的网站2000元代理微信朋友圈广告
  • 杭江建设有限公司厦门seo代理商
  • html5响应式模板seo原创工具
  • 福建参观禁毒展览馆的网站建设香飘飘奶茶
  • 做网站在新闻发稿发布平台
  • 简历模板电子版seo推广优化平台
  • 兰州网页网站如何优化排名
  • 聊城做网站哪家好兰州模板网站seo价格
  • 黄冈网站官方登录平台营销型网站建设服务
  • 网站为什么做静态爱网站关键词查询工具长尾
  • 品牌制作网站下载谷歌浏览器并安装
  • 苏州建设交通官方网站开封网络推广公司
  • 怎样修改网站模板上海公司网站seo
  • 网站APP注册做任务网络营销企业是什么
  • 团购网站开发seo人员的职责
  • 网页制作网站知识网站的推广方式
  • 网站建设技术网站建设百度com打开
  • 苏州网站建设哪家快谷歌搜索引擎免费入口
  • 网站升级建设招标公告湘潭营销型网站建设
  • 制作网站设计的总结mac日本官网入口
  • 资金盘网站开发多少钱长沙百度网站优化
  • 网站开发看书百度一下首页手机版
  • 网站动态url和静态url的优劣势站内seo内容优化包括