HDOJ1050 Moving Tables
来源:互联网 发布:公司数据部门职责 编辑:程序博客网 时间:2024/06/10 19:30
原题链接
更新后:
#include <stdio.h>#include <string.h>#include <algorithm>#define maxn 402using std::max_element;using std::swap;int arr[maxn];int main(){int t, n, a, b;scanf("%d", &t);while(t--){scanf("%d", &n);memset(arr, 0, sizeof(arr));while(n--){scanf("%d%d", &a, &b);if(!(a & 1)) --a;if(!(b & 1)) --b;if(a > b) swap(a, b);while(a <= b) ++arr[a++];}printf("%d\n", *max_element(arr, arr + 400) * 10);}return 0;}
更新前:
#include <stdio.h>struct Node{int begin, end;};Node a[201];int p[401];int main(){int t, n, i, temp, count, j;scanf("%d", &t);while(t--){scanf("%d", &n);for(i = 0; i != n; ++i){scanf("%d%d", &a[i].begin, &a[i].end);if(a[i].begin > a[i].end){temp = a[i].begin;a[i].begin = a[i].end;a[i].end = temp;}if(a[i].begin & 1 == 0) --a[i].begin; //调整门口占用if(a[i].end & 1) ++a[i].end;}for(i = 0; i != n; ++i)for(j = a[i].begin; j <= a[i].end; ++j)++p[j];for(i = count = 0; i != 401; ++i)if(p[i] > count) count = p[i];printf("%d\n", count * 10);for(i = 0; i != 401; ++i)p[i] = 0;}return 0;}
0 0
- HDOJ1050 Moving Tables 贪心
- HDOJ1050 Moving Tables
- hdoj1050 Moving Tables
- hdoj1050 Moving Tables(贪心算法?)
- hdoj1050 moving tables 贪心 最大重叠区间数
- Moving Tables
- Moving Tables
- Moving Tables
- Moving Tables
- Moving Tables
- Moving Tables
- Moving Tables
- Moving Tables
- Moving Tables
- Moving Tables
- Moving Tables
- Moving Tables
- Moving Tables
- java程序员必看书籍
- Ecshop在php 5.3以上版本安装过程中出现的问题
- iOS 6的rotation
- ios获取当前年月日和星期
- ubuntu下打开windows c/cpp等文件中文乱码问题
- HDOJ1050 Moving Tables
- 1069. The Black Hole of Numbers<必看>
- build keil project
- 简单的点对点聊天软件
- 外网访问内网机器
- PHP学习 mysqli 预处理更新
- PAT Basic Level 1023. 组个最小数(20)
- 【2】前台线程和后台线程
- c#操作XML文件的通用方法