본문 바로가기
BaekJoon/C++

5928 : Contest Timing (C++)

by GrayChoi 2021. 2. 24.
반응형

 

5928번: Contest Timing

Bessie the cow is getting bored of the milk production industry, and wants to switch to an exciting new career in computing. To improve her coding skills, she decides to compete in the on-line USACO competitions. Since she notes that the contest starts on

www.acmicpc.net


영어문제는 쉬운거부터 풀어야지

#include<iostream>

using namespace std;

int main() {
    int D, H, M;
    
    cin >> D >> H >> M; // date, hours, minutes

    D -= 11;
    H -= 11;
    M -= 11;

    if(M < 0) {
        H--;
        M += 60;
    }

    if(H < 0) {
        D--;
        H += 24;
    }

    if(D < 0) {
        // D가 음수면 끝나는 시간이 시작시간보다 빠름
        cout << -1 << "\n";
    } else {
        // 하루는 1440분이므로 D*1440
        cout << D*1440 + H*60 + M << "\n";
    }

    return 0;
}
반응형

'BaekJoon > C++' 카테고리의 다른 글

5011 : Robots on a grid (C++)  (0) 2021.02.26
11286 : 절댓값 힙 (C++)  (0) 2021.02.25
2589 : 보물섬 (C++)  (0) 2021.02.24
1927 : 최소 힙 (C++)  (0) 2021.02.24
11279 : 최대 힙 (C++)  (0) 2021.02.24

댓글