F - Color the ball
问题描述:
N个气球排成一排,从左到右依次编号为1,2,3…N.每次给定2个整数a b(a <= b),lele便为骑上他的“小飞鸽"牌电动车从气球a开始到气球b依次给每个气球涂一次颜色。但是N次以后lele已经忘记了第I个气球已经涂过几次颜色了,你能帮他算出每个气球被涂过几次颜色吗?
输入:
每个测试实例第一行为一个整数N,(N <= 100000).接下来的N行,每行包括2个整数a b(1 <= a <= b <= N)。
当N = 0,输入结束。
输出:
每个测试实例输出一行,包括N个整数,第I个数代表第I个气球总共被涂色的次数。
测试样例:
代码:
#include<iostream>
#include<stdio.h>
using namespace std;const int N = 100010;int main(){bool flag = true;while(flag){int A[N]={0},B[N]={0};int n;scanf("%d",&n);if(n==0){flag = false;break;}int m = n;while(m--){int a,b;scanf("%d%d",&a,&b);B[a]++;B[b+1]--;}for(int i=1;i<=n;i++){A[i] = B[i]+A[i-1];printf("%d",A[i]);if(i<n){printf(" ");}}printf("\n");}return 0;
}
F - Color the ball相关推荐
- HDU1556 Color the ball【差分数组+线段树】
Color the ball Time Limit: 9000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Tota ...
- 2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛 F Color it
链接:https://www.nowcoder.com/acm/contest/163/F 来源:牛客网 2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛 F Color it 时间限制:C ...
- hdu 1556 Color the ball
Color the ball Time Limit: 9000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) T ...
- Color the ball
Color the ball Time Limit: 9000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) T ...
- hdu 1556:Color the ball(第二类树状数组 —— 区间更新,点求和)
Color the ball Time Limit: 9000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) T ...
- HDU 1556 Color the ball (数状数组)
Color the ball Time Limit: 9000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) T ...
- 杭电1556 Color the ball
Color the ball Time Limit: 9000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) T ...
- Color the ball(树状数组区间更新+单点求值)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1556 Color the ball Time Limit: 9000/3000 MS (Java/Ot ...
- HDU1556 Color the ball(树状数组+抖机灵)
题目: Color the ball Time Limit: 9000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Other ...
最新文章
- 介绍几款浏览器兼容性测试工具
- java.lang.VerifyError
- 一文读懂比特币现金(BCH)
- python与c语言在语法上的区别-C语言和Python编程先学习哪个
- 一文读懂 Spring的前世今生
- std中稳定排序算法_敏哥:深挖亚马逊A9算法中的广告搜索排序
- 今天早上买的这个猪蹄和花生辣条不是味道
- 2013年最新最热播的电影 合集
- [19/03/12-星期二] 数组_遍历(for-each)复制java.util.Arrays类
- 自定义View(一)-ViewGroup实现优酷菜单
- spark aggregate函数详解
- 功能强大的pdf控件,用户无需安装任何软件即可使用
- Geoserver+postSQL+openlayer实现路径规划
- 弹出框(bootStrap模态框、bootbox、dbailog)
- python苹果手机照片导入电脑_拯救你的16GB iPhone利用Seafile创建私有云将照片同步到PC上...
- php中的单引号和双引号
- oracle数据库字符集US7ASCII,在java中处理中文问题
- 用js代码简单的介绍自己
- php 文字水印换行,thinkPHP5图片加文字水印实现换行的方法
- Linux编译x86架构内核出现_stack_chk_guard未定义错误