#40374: c++ ans


1018harris1018@gmail.com (Harris Chen)

學校 : 不指定學校
編號 : 229825
來源 : [61.230.224.29]
最後登入時間 :
2024-10-20 19:08:01
n630. 電影院 (Cinema) -- TOI練習賽202404新手組第1題 | From: [61.230.231.89] | 發表日期 : 2024-05-15 13:50

#include <iostream>
#include <algorithm>
using namespace std;
int toMinutes(int hour, int minute) {
    return hour * 60 + minute;
}
int main() {
    int N; 
    int movieTimes[1000][100]; 
    cin >> N;
    for (int i = 0; i < N; i++) {
        int movieHour, movieMinute;
        cin >> movieHour >> movieMinute;
        movieTimes[i][0] = movieHour;
        movieTimes[i][1] = movieMinute;
    }
    int ch, cm;
    cin >> ch >> cm;
    int currentTimeInMinutes = toMinutes(ch, cm);
    bool foundMovie = false;
    for (int i = 0; i < N; i++) {
        int movieTimeInMinutes = toMinutes(movieTimes[i][0], movieTimes[i][1]);
        if (movieTimeInMinutes - currentTimeInMinutes >= 20) {
           if(movieTimes[i][0]>=10){
            cout << movieTimes[i][0] << " ";
           }
        else{
            cout<< "0" << movieTimes[i][0] << " ";
        }
        if(movieTimes[i][1]>=10){
          cout << movieTimes[i][1] << endl;
        }
            else {
                 cout << "0" << movieTimes[i][1] << endl;
            }
            foundMovie = true;
            break;
        }
    }
    if (!foundMovie) {
        cout << "Too Late" << endl;
    }
}

 
ZeroJudge Forum