==== 소감 ==== 2005/02/20 Accepted 0:00.002 64 그다지 구상이 필요없는 쉬운 문제였다. 그러나, 출력 오류 잡는데 상당한 시간을 허비했다. 01분과 1분은 분명 다르다. ==== 코드 ==== {{{~cpp // no10191 - Longest Nap #include #include using namespace std; struct Promise { int start; int end; bool operator() (const Promise & a, const Promise & b) { if (a.start < b.start) return true; else return false; } }; const int MAX = 100; const int START_TIME = 10; const int END_TIME = 18; inline void eatline() { while (cin.get() != '\n' && cin.peek() != EOF) continue; }; int make_schedule(Promise * pro); Promise set_naptime(const Promise * pro, const int & nPromise); void show(const Promise & nap, const int & index); int main() { Promise promise[MAX]; int i = 0; while (cin.peek() != EOF) { i++; int nPromise = make_schedule(promise); sort(&promise[0], &promise[nPromise], Promise()); Promise nap = set_naptime(promise, nPromise); show(nap, i); } return 0; } int make_schedule(Promise * pro) { int nPromise; cin >> nPromise; int i; int shour, smin, ehour, emin; for (i=0; i> shour, cin.get(); cin >> smin, cin.get(); cin >> ehour, cin.get(); cin >> emin; eatline(); pro[i].start = shour * 60 + smin; pro[i].end = ehour * 60 + emin; } return nPromise; } Promise set_naptime(const Promise * pro, const int & nPro) { Promise nap; int naptime = pro[0].start - START_TIME * 60; nap.start = START_TIME * 60; int i; for (i=1; i= 60) { cout << during/60 << " hours and " << during%60 << " minutes.\n"; } else cout << during << " minutes.\n"; } }}} ---- [LongestNap] [문보창]