跳到正文

题解

题解:P12641 [KOI 2024 Round 1] 上学

DemonPlayer约 1 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2026年3月29日
篇幅
约 1 分钟
题目
P12641

版本

  1. v1当前

思路:

输入每辆公交车的到达时间和到达学校需要的时间,如果发现到达时间小于等于 xx,那么取到达时间的最大值,输出即可。

C++
#include<bits/stdc++.h>
using namespace std;

int n,x,maxx=-1,s,t;

int main(){
	scanf("%d%d",&n,&x);
	while(n--){
		scanf("%d%d",&s,&t);
		if(s+t<=x){
			maxx=max(maxx,s);
		}
	}
	cout<<maxx;
	return 0;
}
原文