考试2
来源:互联网 发布:matlab 稀疏矩阵求逆 编辑:程序博客网 时间:2024/04/27 12:15
package 考试2;
import java.util.Scanner;
public class Kaoshi2 {
public static int[][] thing;
public static int[] a;
public static int geshu;
public static int max;
public static int res[]=new int[100];
public static int respc=0;
public static boolean isGoOn(int n,int para){ //n=1 para=0
int count=0;
int pc=0;
int thingnstart=thing[n][0]*60+thing[n][1];
int thingnend=thing[n][2]*60+thing[n][3];
if(para==0){
for(int i=0;i<n;i++){
if(a[i]==0) pc++;
if(a[i]==0&&((thingnend<=thing[i][0]*60+thing[i][1])||(thingnstart>=thing[i][2]*60+thing[i][3])))
count++;
}
if(count==pc) return true;
}else if(para==1){
for(int i=0;i<n;i++){
if(a[i]==1) pc++;
if(a[i]==1&&((thingnend<=thing[i][0]*60+thing[i][1])||(thingnstart>=thing[i][2]*60+thing[i][3])))
count++;
}
if(count==pc) return true;
}else{
return true;
}
return false;
}
public static int time(){
int sum=0;
for(int i=0;i<geshu;i++){
if(a[i]!=2) sum+=(thing[i][2]*60+thing[i][3]-(thing[i][0]*60+thing[i][1]));
}
return sum;
}
public static void dFS(int step){
if(step==geshu){
/*for(int i=0;i<geshu;i++){
System.out.print(a[i]+" ");
}
System.out.println();*/
int temptime=time();
if(max<temptime) max=temptime;
return;
}
for(int i=0;i<3;i++){
if(isGoOn(step,i)){//step=1 i=0
a[step]=i;
dFS(step+1);
}
}
}
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int testnum=sc.nextInt();
int iunum=testnum;
while(testnum-->0){
max=0;
geshu=sc.nextInt();
a=new int[geshu];
thing=new int[geshu][4];
for(int i=0;i<geshu;i++){
for(int j=0;j<4;j++){
thing[i][j]=sc.nextInt();
}
}
dFS(0);
res[respc++]=max;
}
for(int i=0;i<iunum;i++){
System.out.println(res[i]);
}
}
}
- 考试2
- 本次考试总结(2017.9.2考试)
- 考试练习2
- 在线考试(2)
- 软件设计师考试2
- 数学考试 2
- 11.5 考试驾到2
- 嵌入式考试2
- 考试2 矩阵填充
- 数学考试2(test20170311)
- 数学考试2(test20170311)
- 集训考试2
- 考试总结2
- 20191021考试总结2
- 考试
- 考试!
- 考试
- 考试
- 广度优先搜索_suuccess
- spring mvc 下载文件 IE浏览器文件名是乱码
- 考试1
- 使用Appium测试Hybrid App的方法
- linux 文档的压缩和打包
- 考试2
- SVN和GIT的比较(一)
- Spring ,Springmvc,mybatis三大框架整合的配置文件支持
- Matlab 球坐标-直角坐标转换sph2cart
- 自定义滚动条插件
- oracle 索引
- http状态码
- 关注会议
- 正方形;