Day 49 C. Exams

一名大学生要在n场考试中遵循非递减日期记录成绩的原则。每场考试的原定日期为ai,提前日期为bi(bi < ai)。求最早的完成所有考试的日期。输入包含n对ai和bi,输出是最小的最后考试日期。

Problem
Student Valera is an undergraduate student at the University. His end of term exams are approaching and he is to pass exactly n exams. Valera is a smart guy, so he will be able to pass any exam he takes on his first try. Besides, he can take several exams on one day, and in any order.

According to the schedule, a student can take the exam for the i-th subject on the day number ai. However, Valera has made an arrangement with each teacher and the teacher of the i-th subject allowed him to take an exam before the schedule time on day bi (bi < ai). Thus, Valera can take an exam for the i-th subject either on day ai, or on day bi. All the teachers put the record of the exam in the student’s record book on the day of the actual exam and write down the date of the mark as number ai.

Valera believes that it would be rather strange if the entries in the record book did not go in the order of non-decreasing date. Therefore Valera asks you to help him. Find the minimum possible value of the day when Valera can take the final exam if he takes exams so that all the records in his record book go in the order of non-decreasing date.

Input
The first line contains a single positive integer n (1 ≤ n ≤ 5000) — the number of exams Valera will take.

Each of the next n lines contains two positive space-separated integers ai and bi (1 ≤ bi < ai ≤ 109) — the date of the exam in the schedule and the early date of passing the i-th exam, correspondingly.

Output
Print a single integer — the minimum possible number of the day when Valera can take the last exam if he takes all the exams so that all the records in his record book go in the order of non-decreasing date.

Examples
input
3
5 2
3 1
4 2
output
2

input
3
6 1
5 2
4 3
output
6

Note
In the first sample Valera first takes an exam in the second subject on the first day (the teacher writes down the schedule date that is 3). On the next day he takes an exam in the third subject (the teacher writes down the schedule date, 4), then he takes an exam in the first subject (the teacher writes down the mark with date 5). Thus, Valera takes the last exam on the second day and the dates will go in the non-decreasing order: 3, 4, 5.

In the second sample Valera first takes an exam in the third subject on the fourth day. Then he takes an exam in the second subject on the fifth day. After that on the sixth day Valera takes an exam in the first subject.

题目大致意思为:一个学生,要参加n场考试,但是他想尽快的把所有考试都考完。
对于第 i 场考试,老师规定的时间是ai, 他自己安排的时间是bi ,且ai > bi 。
现在有一个原则,你的考试时间顺序不能和老师安排的每场考试时间的先后顺序不一致,且这个学生可以在同一时间完成无穷多的考试。
求他完成全部考试的最早时间是多少。
//pair记录老师给的时间和自己所需时间 排序后取最小值

#include<iostream>
#include<algorithm>
#include<string.h>
#include<vector>
#include<stdio.h>
#include<limits.h>
#include<queue>
#include<cmath>
#include<set>
#include<map>
using namespace std;
int main()
{
	int n;
	cin >> n;
	pair<int, int>p[5005];
	for (int i = 0; i < n; i++)
	{
		cin >> p[i].first >> p[i].second;
	}
	sort(p, p + n);
	int res = 0;
	for (int i = 0; i < n; i++)
	{
		if (res > p[i].second)
		{
			res = p[i].first;
		}
		else
		{
			res = max(res, p[i].second);
		}
	}
	cout << res << endl;
	return 0;
}
df head(df) sleep_hours1 <- df$When.have.you.usually.gone.to.bed.in.the.past.month. sleep_hours2<-df$What.time.have.you.usually.gotten.up.in.the.morning.in.the.past.month. fall_asleep_time <- df$How.long.has.it.taken.you.to.fall.asleep.each.night.in.the.past.month. var1<-df$Cannot.get.to.sleep.within.30.minutes var2<-df$Wake.up.in.the.middle.of.the.night.or.early.morning var3<-df$Have.to.get.up.to.use.the.bathroom var4<-df$Cough.or.snore.loudly var5<-df$Feel.too.cold var6<-df$Feel.too.hot var7<-df$Have.bad.dreams var8<-df$Have.pain disturbance_vars <- cbind(var1, var2, var3, var4, var5, var6, var7, var8) colnames(disturbance_vars) <- c("Cannot get to sleep within 30 minutes", "Wake up in the middle of the night or early morning", "Have to get up to use the bathroom", "Cough or snore loudly", "Feel too cold", "Feel too hot", "Have bad dreams", "Have pain") disturbance_vars gender <- as.factor(df[["Gender"]]) gender X <- data.frame( fall_asleep_time, sleep_hours1, sleep_hours2, disturbance_vars, gender ) s1<-df$You.have.to.submit.an.assignment.in.less.than.a.day s2<-df$A.week.before.exams s3<-df$Asking.for.an.extra.ketchup.packet.at.a.restaurant s4<-df$Meeting.a.new.person s5<-df$Asking.for.help s6<-df$Confronting.someone s7<-df$Doing.something.without.help stress_cols <- cbind(s1,s2,s3,s4,s5,s6,s7) colnames(stress_cols) <- c("You have to submit an assignment in less than a day", "A week before exams", "Asking for an extra ketchup packet at a restaurant", "Meeting a new person", "Asking for help", "Confronting someone", "Doing something without help") stress_scores <- rowMeans(stress_cols) Y <- ifelse(stress_scores > median(stress_scores), 1, 0) Y model <- glm( Y ~., data = X, family = binomial(link = "logit") ) summary(model) step_model <- step( model, direction = "both", trace = 1 ) summary(step_model) 这是我的数据,然后我每次都会出现[.data.frame`(model_data, , rn, drop = FALSE):这个错误
06-05
`org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)` 错误通常表示 MyBatis 无法找到指定的 SQL 映射语句。以下是可能的解决方法: ### 1. 检查映射文件路径和命名空间 确保 `UserMapper.xml` 文件存在,并且路径配置正确。同时,要保证 `UserMapper.xml` 文件中的 `namespace` 属性值与 `UserMapper` 接口的全限定名一致。 ```xml <!-- UserMapper.xml --> <mapper namespace="com.lititi.exams.web.dao.UserMapper"> <!-- SQL 语句 --> <select id="selectById" resultType="com.lititi.exams.web.entity.User"> SELECT * FROM user WHERE id = #{id} </select> </mapper> ``` ### 2. 检查接口方法和映射语句的 ID 要确保 `UserMapper` 接口中的方法名和 `UserMapper.xml` 文件中的 SQL 语句的 `id` 属性一致。 ```java // UserMapper.java package com.lititi.exams.web.dao; import com.lititi.exams.web.entity.User; public interface UserMapper { User selectById(Long id); } ``` ### 3. 检查配置文件 确认 MyBatis 的配置文件(如 `mybatis-config.xml` 或 Spring 配置文件)中是否正确配置了映射文件。 ```xml <!-- mybatis-config.xml --> <mappers> <mapper resource="com/lititi/exams/web/dao/UserMapper.xml"/> </mappers> ``` 如果是 Spring Boot 项目,通常在 `application.properties` 或 `application.yml` 中配置: ```properties # application.properties mybatis.mapper-locations=classpath:com/lititi/exams/web/dao/*.xml ``` ```yaml # application.yml mybatis: mapper-locations: classpath:com/lititi/exams/web/dao/*.xml ``` ### 4. 检查编译输出 确保 `UserMapper.xml` 文件被正确编译到了目标目录(通常是 `target/classes` 或 `build/classes`)。 ### 5. 检查 Maven 或 Gradle 配置 如果使用 Maven,确保 `pom.xml` 中配置了资源过滤: ```xml <build> <resources> <resource> <directory>src/main/java</directory> <includes> <include>**/*.xml</include> </includes> </resource> <resource> <directory>src/main/resources</directory> </resource> </resources> </build> ``` 如果使用 Gradle,确保 `build.gradle` 中配置了资源过滤: ```groovy sourceSets { main { resources { srcDirs = ['src/main/resources', 'src/main/java'] include '**/*.xml' } } } ``` ### 6. 检查数据库连接 确保数据库连接正常,并且表结构和字段名与 SQL 语句中的一致。 ### 7. 检查缓存 有时候缓存会导致问题,可以尝试清除缓存并重新启动项目。 ### 8. 检查 MyBatis 版本 确保 MyBatis 及其相关依赖的版本兼容。 ### 9. 检查注解使用 如果使用了注解方式编写 SQL,确保注解使用正确。 ```java // UserMapper.java package com.lititi.exams.web.dao; import com.lititi.exams.web.entity.User; import org.apache.ibatis.annotations.Select; public interface UserMapper { @Select("SELECT * FROM user WHERE id = #{id}") User selectById(Long id); } ```
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值