分时间uu
#include<stdio.h> int map[20][4]; typedef struct node{ int star; int end; }node; node dui[100]; int step[14]; int max=0; int sum; int cass; int N; int flag; void pan(int a[]) { flag=0; sum=0; int q=-1; int p=-1; for(int i=0;i<N;i++) { if(a[i]==0) { if(dui[i].star>=dui[q].end) { sum=sum+dui[i].end-dui[i].star; q=i; } else return; } else if(a[i]==1) { if(dui[i].star>=dui[p].end) { sum=sum+dui[i].end-dui[i].star; p=i; } else return; } } flag=1; }
void dfs(int a) { if(a==N) { pan(step); if(max<sum&&flag==1) max=sum; return; } for(int i=0;i<=2;i++) { step[a]=i; dfs(a+1); } } int main() { freopen("in.txt","r",stdin); scanf("%d",&cass); while(cass--) { scanf("%d",&N); node tmp; max=0; for(int i=0;i<N;i++) { for(int j=0;j<4;j++) { scanf("%d",&map[i][j]); } } for(int i=0;i<N;i++) { dui[i].star=map[i][0]*60+map[i][1]; dui[i].end=map[i][2]*60+map[i][3]; } for(int a=0;a<N-2;a++) { for(int b=0;b<N-2;b++) { if(dui[b].star>dui[b+1].star) { tmp=dui[b]; dui[b]=dui[b+1]; dui[b+1]=tmp; } } } dfs(0); printf("%d\n",max); } return 0; }
分时间uu的更多相关文章
- BFS:HDU2597-Dating with girls(2) (分时间标记状态)
Dating with girls(2) Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Oth ...
- 成都项目中因为MYSQL与SSDB备分时间不一致,导致主键产生器错误解决一例
-- JFinal错误提示 Duplicate entry '1791361-1823391' for key 'PRIMARY' -- 1.查看SSDB的主键生成器值ssdb 127.0.0.1:8 ...
- Hibernate中HQL函数汇总及获取当前时间进行比较举例
在很多时候,我们负责的项目中,在数据访问层(DAO层)通常我们会使用sql语句或者hql语句,而在我们使用hql语句拼接时有时会报错,通常的原因是:我们使用了标准的sql语句,开启的确是hiberna ...
- iOS性能优化-数组、字典便利时间复杂
上图是几种时间复杂度的关系,性能优化一定程度上是为了降低程序执行效率减低时间复杂度. 如下是几种时间复杂度的实例: O(1) return array[index] == value; 复制代码 O( ...
- 暑期集训日志(Day0~Day5)
章·五:2019-07-15:明月不谙离恨苦,斜光到晓穿朱户 ·昨日小结: 昨天考试又是爆零边缘,除了难过就剩难过了. T1暴力打崩了只拿了5分. T2没给分时间.最后20分钟打了个残码.没仔细观察数 ...
- PHPExcel 大数据的导出
PHPExcel 是一个php语言读取导出数据.导入生成Excel的类库,使用起来非常方便,但有时会遇到以些问题,比如导出的数据超时,内存溢出等. 下面我们来说说这些问题和解决办法. PHPExcel ...
- IT 外包中的甲方乙方,德国人,美国人,印度人和日本人印象杂谈
开篇介绍 最近经常和朋友聚会,三十而立的年龄自然讨论最多的就是各自的小家庭,如何赚钱,工作,未来的就业发展,职业转型等话题.还有各种跳槽,机会选择,甲方乙方以及外包中的各种趣事,外企与国内私企的发展机 ...
- MySQL 第九天(核心优化三)
一.昨天内容回顾 索引设计依据 与数据表有关系的sql语句都统计出来 where order by or等等条件的字段适当做索引 原则: 频率高的sql语句 执行时间长的sql语句 业务逻辑重要的sq ...
- 二模02day1解题报告
T1.淘汰赛制 比赛时的淘汰赛制,给出每两个球队比赛的胜率,求出最终胜率最高的队伍. 这题的概率真的很难算啊感觉...一开始打的代码打下来就是用f[i][j]表示i场比赛后第j人还在场的概率.不难看出 ...
随机推荐
- js中for in 和 for each in的用法和区别
区别一: for in是javascript 1.0 中发布的. for each in是作为E4X标准的一部分在javascript 1.6中发布的,而它不是EC ...
- UVa1515 Pool construction(最小割)
题目 Source https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_pr ...
- ural 1346. Intervals of Monotonicity
1346. Intervals of Monotonicity Time limit: 1.0 secondMemory limit: 64 MB It’s well known that a dom ...
- iOS之01-基本语法
视频iOS是本人通过视频学习,初期并不是直接使用Xcode,而是在命令行下创建文件.打开文件.编译文件和运行文件. #import <Foundation/Foundation.h> in ...
- Android AsyncTask
AsyncTask类任务管理: 内部会创建一个进程作用域的线程池来管理要运行的任务,也就就是说当你调用了AsyncTask#execute()后,AsyncTask会把任务交给线程池,由线程池来管理创 ...
- [杂谈] There is a Doctor in My Computer.
(p.s. 附带手写翻译,有错轻喷) Admin: Hi. (嗨) Doctor: How do you do? What brings you to see me? ...
- Java 仿迅雷多线程下载
package net.webjoy.jackluo.android_json; /** * 1.http Range "bytes="+ start+end * 2.Random ...
- [CareerCup] 17.7 English Phrase Describe Integer 英文单词表示数字
17.7 Given any integer, print an English phrase that describes the integer (e.g., "One Thousand ...
- [CareerCup] 17.4 Maximum of Two Numbers 两数中的较大值
17.4 Write a method which finds the maximum of two numbers. You should not use if-else or any other ...
- ado.net 实体类_数据访问类
实体类: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ...