CodeFoeces-967A

题目

原题链接:A. Mind the Gap

题意

有n架次航班的降落时间表,飞机降落需要1分钟。现要在空档期起飞一架航班,需求是前后s钟内没有降落的航班。问最早何时能起飞。

代码

#include
using namespace std;
int main() {
    int n,s,h[100],m[100],ans;
    cin>>n>>s;
    for(int i=0; i>h[i]>>m[i];
    }
    for(int i=0; i s){
                printf("0 0\n");
                return 0;
            }
        }else{
            int tmp1 = h[i-1]*60+m[i-1],tmp2 = h[i]*60+m[i];
            if( tmp2-tmp1-1 > 2*s){
                int ans = tmp1+s+1;
                printf("%d %d\n",ans/60,ans%60);
                return 0;
            }
        }
    }
    ans = h[n-1]*60+m[n-1]+s+1;
    printf("%d %d\n",ans/60,ans%60);
    return 0;
}

你可能感兴趣的:(CodeFoeces-967A)