codeforces 967A A. Mind the Gap ( Round #477 rated, Div. 2)
阿新 • • 發佈:2019-01-04
題意: 告訴一系列飛機降落時間,而且降落需要1秒,相鄰飛機降落必須間隔S,就是前一個飛機降落了之後(+1s)+s才可以安排下一個飛機。問多安排一個飛機的最早降落時間
不知道為什麼那麼多人fst,好了直接上程式碼:
// >File Name: 1.cpp // > Author: Webwei #include<bits/stdc++.h> #define ll long long using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int n,s; cin >> n >> s; int a[110]; int hh,mm; int tt = 0; for(int i=0;i<n;i++) cin >> hh >> mm, a[i] = hh * 60 + mm; //for(int i=0;i<n;i++) cout << a[i]<< endl; int flag = 1; if(s+1<=a[0] && flag) tt = 0,flag = 0; for(int i=1;i<n;i++){ if(s+1<=(a[i]-a[i-1]-s-1) && flag) tt = a[i-1]+s+1,flag = 0; } if(flag) tt = a[n-1]+s+1; int h = tt/60; int m = tt -tt/60*60; //while(h>24) h-=24; cout << h << " " << m << endl; return 0; }