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

· · 题解

思路:

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

#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;
}