#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

typedef int WORD;
 
typedef struct _SYSTEMTIME {
  WORD wYear;
  WORD wMonth;
  WORD wDayOfWeek;
  WORD wDay;
  WORD wHour;
  WORD wMinute;
  WORD wSecond;
  WORD wMilliseconds;
} SYSTEMTIME;

class ClosestTo {
    int minute_now;
    int abs_minute(const SYSTEMTIME& t) const {
        return 60 * (24 * t.wDayOfWeek + t.wHour) + t.wMinute;
    }
    int diff_to_now(const SYSTEMTIME& t) const {
        int res = abs_minute(t) - minute_now;
        // Has it passed?
        if (res < 0) {
            // Move to next week
            res += 7*24*60;
        }
        return res;
    }
public:
    ClosestTo(const SYSTEMTIME& now)
    :   minute_now(abs_minute(now)) {
    }
    bool operator() (const SYSTEMTIME& lhs, const SYSTEMTIME& rhs) const {
        return diff_to_now(lhs) < diff_to_now(rhs);
    }
};

int main() {
    SYSTEMTIME m_MatchTime[3];

    // Monday: 00:00
    m_MatchTime[0].wDayOfWeek = 1;
    m_MatchTime[0].wHour = 22;
    m_MatchTime[0].wMinute = 4;
 
    // Sunday: 01:00
    m_MatchTime[1].wDayOfWeek = 4;
    m_MatchTime[1].wHour = 1;
    m_MatchTime[1].wMinute = 0;
 
    // Wednesday: 15:30
    m_MatchTime[2].wDayOfWeek = 6;
    m_MatchTime[2].wHour = 15;
    m_MatchTime[2].wMinute = 30;
 
    // Sunday 23:00
    SYSTEMTIME cTime;
    cTime.wDayOfWeek = 3;
    cTime.wHour = 14;
    cTime.wMinute = 5;

    ClosestTo cmp(cTime);
    sort(m_MatchTime, m_MatchTime+3, cmp);

    SYSTEMTIME &nearest = m_MatchTime[0];
    cout << "CurrentTime\n"  
    << "Day:" << cTime.wDayOfWeek
    << "Hour:" << cTime.wHour
    << "Min:" << cTime.wMinute 
 
    << "\nDay:" << nearest.wDayOfWeek
    << "Hour:" << nearest.wHour
    << "Min:" << nearest.wMinute << endl;
	return 0;
}