lightoj 1016
水题,排个序直接搞。
#include<cstdio>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int MAXN = 50010;
int y[MAXN];
int main(){
int t, x, n, w, CASE(0);
scanf("%d", &t);
while(t--){
scanf("%d%d", &n, &w);
for(int i = 0;i < n;i ++) scanf("%d%d", &x, y+i);
sort(y, y+n);
int ans(0);
for(int i = 0;i < n;i ++){
ans ++;
for(int j = i; y[i]-y[j] <= w; i ++);
i--;
}
printf("Case %d: %d\n", ++CASE, ans);
}
return 0;
}
lightoj 1016的更多相关文章
- Lightoj 1016 - Brush (II)
After the long contest, Samee returned home and got angry after seeing his room dusty. Who likes to ...
- lightoj刷题日记
提高自己的实力, 也为了证明, 开始板刷lightoj,每天题量>=1: 题目的类型会在这边说明,具体见分页博客: SUM=54; 1000 Greetings from LightOJ [简单 ...
- 【BZOJ 1016】【JSOI 2008】最小生成树计数
http://www.lydsy.com/JudgeOnline/problem.php?id=1016 统计每一个边权在最小生成树中使用的次数,这个次数在任何一个最小生成树中都是固定的(归纳证明). ...
- 区间DP LightOJ 1422 Halloween Costumes
http://lightoj.com/volume_showproblem.php?problem=1422 做的第一道区间DP的题目,试水. 参考解题报告: http://www.cnblogs.c ...
- LightOj 1298 - One Theorem, One Year(DP + 欧拉)
题目链接:http://lightoj.com/volume_showproblem.php?problem=1298 题意:给你两个数 n, p,表示一个数是由前 k 个素数组成的,共有 n 个素数 ...
- 1016. Boundaries on A New Kind of Science 解题报告
题目链接: http://soj.sysu.edu.cn/1016 题目大意: 给定一个字符串和256条规则,将某条规则应用于字符串,字符串将发生变化,给定一个数max,求出在max步内可以将字符串变 ...
- one recursive approach for 3, hdu 1016 (with an improved version) , permutations, N-Queens puzzle 分类: hdoj 2015-07-19 16:49 86人阅读 评论(0) 收藏
one recursive approach to solve hdu 1016, list all permutations, solve N-Queens puzzle. reference: t ...
- 1214 - Large Division -- LightOj(大数取余)
http://lightoj.com/volume_showproblem.php?problem=1214 这就是一道简单的大数取余. 还想还用到了同余定理: 所谓的同余,顾名思义,就是许多的数被一 ...
- LightOJ Beginners Problems 部分题解
相关代码请戳 https://coding.net/u/tiny656/p/LightOJ/git 1006 Hex-a-bonacci. 用数组模拟记录结果,注意取模 1008 Fibsieve's ...
随机推荐
- My97DatePicker{js日历插件}
VS自带了一个日历控件:Calendar,但是它有一个缺陷:即在选择,隐藏,显示的时候都会引起回传 Calendar控件的一些用法: 取值:Calendar1.SelectedDate.ToSh ...
- 第二好用的时间日期选择插件(jscal)
这个是第二好用的了,支持鼠标滚动选择时间.功能很强大,文档:http://www.dynarch.com/jscal/ 效果图: <!DOCTYPE html PUBLIC ...
- linux复制多个文件到文件夹
linux复制多个文件到文件夹 cp file1 file2 file3 directory即将文件file1 file2 file3复制到directory
- HTML <iframe> 标签
参考地址:http://www.w3school.com.cn/tags/tag_iframe.asp ------------------------------------------------ ...
- PAT-乙级-1033. 旧键盘打字(20)
1033. 旧键盘打字(20) 时间限制 200 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue 旧键盘上坏了几个键,于是在敲一段文 ...
- PAT-乙级-1013. 数素数 (20)
1013. 数素数 (20) 时间限制 100 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue 令Pi表示第i个素数.现任给两个正整 ...
- 定长内存池之BOOST::pool
内存池可有效降低动态申请内存的次数,减少与内核态的交互,提升系统性能,减少内存碎片,增加内存空间使用率,避免内存泄漏的可能性,这么多的优点,没有理由不在系统中使用该技术. 内存池分类: 1. ...
- Head First 设计模式笔记:单例模式
单例模式 确保一个类只有一个实例,并提供一个全局访问点. 类图: Singleton static uniqueInstance //其他属性... static getInstance() //其他 ...
- 将ANGULAR与后端请求结合
简单的结合,却是很多应用的基础.RESTFUL就此而生.瘦服务,富客户. <!DOCTYPE html> <html lang="en" ng-app=" ...
- 107. Binary Tree Level Order Traversal II
题目: Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from ...